Fixed map padding
This commit is contained in:
parent
766df57d5f
commit
38b741dbb1
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package org.gcube.accounting.analytics;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
|
@ -15,6 +16,18 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
|||
*/
|
||||
public class Info {
|
||||
|
||||
public static final String DATETIME_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS Z";
|
||||
|
||||
public static DateFormat getDateFormat() {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATETIME_PATTERN);
|
||||
simpleDateFormat.setTimeZone(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
return simpleDateFormat;
|
||||
}
|
||||
|
||||
public static String format(Calendar calendar) {
|
||||
return getDateFormat().format(calendar.getTime());
|
||||
}
|
||||
|
||||
protected Calendar calendar;
|
||||
protected JsonNode value;
|
||||
|
||||
|
@ -58,8 +71,6 @@ public class Info {
|
|||
|
||||
@Override
|
||||
public String toString(){
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SS z");
|
||||
simpleDateFormat.setTimeZone(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
return String.format("Date : %s, Value : %s", simpleDateFormat.format(calendar.getTime()), value.toString());
|
||||
return String.format("Date : %s, Value : %s", format(calendar), value.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
|
|||
switch (key) {
|
||||
case AggregatedRecord.START_TIME:
|
||||
break;
|
||||
|
||||
|
||||
case AggregatedRecord.END_TIME:
|
||||
break;
|
||||
|
||||
|
@ -170,7 +170,9 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
|
|||
for (Calendar progressTime : sequence) {
|
||||
Info info = unpaddedData.get(progressTime);
|
||||
if (info == null) {
|
||||
info = new Info(progressTime, jsonNode);
|
||||
ObjectNode objectNode = jsonNode.deepCopy();
|
||||
objectNode.put(AggregatedStorageUsageRecord.START_TIME, Info.format(progressTime));
|
||||
info = new Info(progressTime, objectNode);
|
||||
unpaddedData.put(progressTime, info);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue