use of org.joda.time.DateTimeZone in project gephi by gephi.
the class IntervalMapSparklinesGraphicsComponentProvider method getTextFromValue.
@Override
public String getTextFromValue(Object value) {
if (value == null) {
return null;
}
TimeFormat timeFormat = graphModelProvider.getGraphModel().getTimeFormat();
DateTimeZone timeZone = graphModelProvider.getGraphModel().getTimeZone();
return ((IntervalMap) value).toString(timeFormat, timeZone);
}
use of org.joda.time.DateTimeZone in project gephi by gephi.
the class TimestampMapSparklinesGraphicsComponentProvider method getTextFromValue.
@Override
public String getTextFromValue(Object value) {
if (value == null) {
return null;
}
TimeFormat timeFormat = graphModelProvider.getGraphModel().getTimeFormat();
DateTimeZone timeZone = graphModelProvider.getGraphModel().getTimeZone();
return ((TimestampMap) value).toString(timeFormat, timeZone);
}
use of org.joda.time.DateTimeZone in project gephi by gephi.
the class AttributeTypesSupportCellEditor method getTableCellEditorComponent.
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
TimeFormat timeFormat = graphModelProvider.getGraphModel().getTimeFormat();
DateTimeZone timeZone = graphModelProvider.getGraphModel().getTimeZone();
String valueStr;
if (value == null) {
valueStr = "";
} else if (isTimestampSetType) {
valueStr = ((TimestampSet) value).toString(timeFormat, timeZone);
} else if (isTimestampMapType) {
valueStr = ((TimestampMap) value).toString(timeFormat, timeZone);
} else if (isIntervalSetType) {
valueStr = ((IntervalSet) value).toString(timeFormat, timeZone);
} else if (isIntervalMapType) {
valueStr = ((IntervalMap) value).toString(timeFormat, timeZone);
} else if (isArrayType) {
valueStr = AttributeUtils.printArray(value);
} else if (isDecimalType) {
valueStr = DoubleStringConverter.FORMAT.format(value);
} else {
valueStr = AttributeUtils.print(value, timeFormat, timeZone);
}
textField.setBorder(originalBorder);
textField.setEditable(true);
textField.setText(valueStr);
return textField;
}
use of org.joda.time.DateTimeZone in project presto by prestodb.
the class GenericHiveRecordCursor method getLongExpressedValue.
private static long getLongExpressedValue(Object value, DateTimeZone hiveTimeZone) {
if (value instanceof Date) {
long storageTime = ((Date) value).getTime();
// convert date from VM current time zone to UTC
long utcMillis = storageTime + DateTimeZone.getDefault().getOffset(storageTime);
return TimeUnit.MILLISECONDS.toDays(utcMillis);
}
if (value instanceof Timestamp) {
// The Hive SerDe parses timestamps using the default time zone of
// this JVM, but the data might have been written using a different
// time zone. We need to convert it to the configured time zone.
// the timestamp that Hive parsed using the JVM time zone
long parsedJvmMillis = ((Timestamp) value).getTime();
// remove the JVM time zone correction from the timestamp
DateTimeZone jvmTimeZone = DateTimeZone.getDefault();
long hiveMillis = jvmTimeZone.convertUTCToLocal(parsedJvmMillis);
// convert to UTC using the real time zone for the underlying data
long utcMillis = hiveTimeZone.convertLocalToUTC(hiveMillis, false);
return utcMillis;
}
if (value instanceof Float) {
return floatToRawIntBits(((Float) value));
}
return ((Number) value).longValue();
}
use of org.joda.time.DateTimeZone in project druid by druid-io.
the class Granularity method granularitiesFinerThan.
public static List<Granularity> granularitiesFinerThan(final Granularity gran0) {
final DateTime epoch = new DateTime(0);
final List<Granularity> retVal = Lists.newArrayList();
final DateTime origin = (gran0 instanceof PeriodGranularity) ? ((PeriodGranularity) gran0).getOrigin() : null;
final DateTimeZone tz = (gran0 instanceof PeriodGranularity) ? ((PeriodGranularity) gran0).getTimeZone() : null;
for (GranularityType gran : GranularityType.values()) {
/**
* All and None are excluded b/c when asked to give all granularities finer
* than "TEN_MINUTE", you want the answer to be "FIVE_MINUTE, MINUTE and SECOND"
* it doesn't make sense to include ALL or None to be part of this.
*/
if (gran == GranularityType.ALL || gran == GranularityType.NONE) {
continue;
}
final Granularity segmentGranularity = gran.create(origin, tz);
if (segmentGranularity.bucket(epoch).toDurationMillis() <= gran0.bucket(epoch).toDurationMillis()) {
retVal.add(segmentGranularity);
}
}
Collections.sort(retVal, new Comparator<Granularity>() {
@Override
public int compare(Granularity g1, Granularity g2) {
return Longs.compare(g2.bucket(epoch).toDurationMillis(), g1.bucket(epoch).toDurationMillis());
}
});
return retVal;
}
Aggregations