Search in sources :

Example 16 with DateTimeZone

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);
}
Also used : TimeFormat(org.gephi.graph.api.TimeFormat) DateTimeZone(org.joda.time.DateTimeZone) IntervalMap(org.gephi.graph.api.types.IntervalMap)

Example 17 with DateTimeZone

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);
}
Also used : TimeFormat(org.gephi.graph.api.TimeFormat) TimestampMap(org.gephi.graph.api.types.TimestampMap) DateTimeZone(org.joda.time.DateTimeZone)

Example 18 with DateTimeZone

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;
}
Also used : TimeFormat(org.gephi.graph.api.TimeFormat) IntervalSet(org.gephi.graph.api.types.IntervalSet) TimestampSet(org.gephi.graph.api.types.TimestampSet) DateTimeZone(org.joda.time.DateTimeZone)

Example 19 with DateTimeZone

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();
}
Also used : Timestamp(java.sql.Timestamp) Date(java.sql.Date) DateTimeZone(org.joda.time.DateTimeZone)

Example 20 with DateTimeZone

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;
}
Also used : DateTime(org.joda.time.DateTime) DateTimeZone(org.joda.time.DateTimeZone)

Aggregations

DateTimeZone (org.joda.time.DateTimeZone)263 DateTime (org.joda.time.DateTime)123 ArrayList (java.util.ArrayList)36 Test (org.testng.annotations.Test)35 LocalDate (org.joda.time.LocalDate)27 Test (org.junit.Test)21 TimeIntervalRounding (org.elasticsearch.common.rounding.Rounding.TimeIntervalRounding)18 TimeUnitRounding (org.elasticsearch.common.rounding.Rounding.TimeUnitRounding)18 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)17 IOException (java.io.IOException)16 HashMap (java.util.HashMap)15 UUID (java.util.UUID)14 TimeFormat (org.gephi.graph.api.TimeFormat)13 MetricExpression (com.linkedin.thirdeye.client.MetricExpression)12 Date (java.util.Date)12 Chronology (org.joda.time.Chronology)12 LocalDateTime (org.joda.time.LocalDateTime)12 DefaultBlockingState (org.killbill.billing.junction.DefaultBlockingState)11 LocalTime (org.joda.time.LocalTime)10 SubscriptionBaseTransition (org.killbill.billing.subscription.api.user.SubscriptionBaseTransition)10