List of usage examples for org.joda.time DateTime withZone
public DateTime withZone(DateTimeZone newZone)
From source file:io.kazuki.v0.store.keyvalue.KeyValueStoreJdbiBaseImpl.java
License:Apache License
private int doInsert(Handle handle, final ResolvedKey resolvedKey, final VersionImpl schemaVersion, byte[] valueBytes, DateTime date) { Long schemaVersionLong = schemaVersion != null ? schemaVersion.getInternalIdentifier() : 0L; Update update = JDBIHelper.getBoundStatement(handle, getPrefix(), "kv_table_name", tableName, "kv_create"); update.bind("key_type", resolvedKey.getTypeTag()); update.bind("key_id_hi", resolvedKey.getIdentifierHi()); update.bind("key_id_lo", resolvedKey.getIdentifierLo()); update.bind("created_dt", date.withZone(DateTimeZone.UTC).getMillis() / 1000); update.bind("version", 1L); update.bind("schema_version", schemaVersionLong); update.bind("value", valueBytes); int inserted = update.execute(); return inserted; }
From source file:io.sidecar.notification.EventNotification.java
License:Apache License
@SuppressWarnings("unused") private EventNotification(NotificationRule rule, UUID orgId, UUID appId, UUID userId, DateTime timestamp) { this.id = UUID.randomUUID(); this.rule = checkNotNull(rule); this.orgId = checkNotNull(orgId); this.appId = checkNotNull(appId); this.userId = checkNotNull(userId); this.timestamp = timestamp != null ? timestamp.withZone(UTC) : nowUtc(); }
From source file:name.gano.astro.time.Time.java
License:Open Source License
/** Constructor from Joda DateTime **/ public Time(DateTime time) { time.withZone(DateTimeZone.forTimeZone(tz)); currentTime = time.toGregorianCalendar(); updateTimeMeasures();/* w w w.java 2 s .c o m*/ }
From source file:net.hellonico.jodatime.TimeLibrary.java
License:Open Source License
public DateTime getTime(String location) { DateTimeZone zone = DateTimeZone.forID(location); DateTime dt = new DateTime(); return dt.withZone(zone); }
From source file:org.apache.drill.exec.vector.complex.fn.BasicJsonOutput.java
License:Apache License
@Override public void writeDate(DateTime value) throws IOException { gen.writeString(dateFormatter.print(value.withZone(DateTimeZone.UTC))); }
From source file:org.apache.drill.exec.vector.complex.fn.BasicJsonOutput.java
License:Apache License
@Override public void writeTime(DateTime value) throws IOException { gen.writeString(timeFormatter.print(value.withZone(DateTimeZone.UTC))); }
From source file:org.apache.drill.exec.vector.complex.fn.BasicJsonOutput.java
License:Apache License
@Override public void writeTimestamp(DateTime value) throws IOException { gen.writeString(timestampFormatter.print(value.withZone(DateTimeZone.UTC))); }
From source file:org.apache.druid.sql.calcite.planner.Calcites.java
License:Apache License
/** * Calcite expects "DATE" types to be number of days from the epoch to the UTC date matching the local time fields. * * @param dateTime joda timestamp// w w w . ja va 2 s . c o m * @param timeZone session time zone * * @return Calcite style date */ public static int jodaToCalciteDate(final DateTime dateTime, final DateTimeZone timeZone) { final DateTime date = dateTime.withZone(timeZone).dayOfMonth().roundFloorCopy(); return Days.daysBetween(DateTimes.EPOCH, date.withZoneRetainFields(DateTimeZone.UTC)).getDays(); }
From source file:org.apache.druid.sql.calcite.planner.Calcites.java
License:Apache License
/** * Calcite expects TIMESTAMP literals to be represented by TimestampStrings in the local time zone. * * @param dateTime joda timestamp/*from w w w. jav a 2 s. c o m*/ * @param timeZone session time zone * * @return Calcite style Calendar, appropriate for literals */ public static TimestampString jodaToCalciteTimestampString(final DateTime dateTime, final DateTimeZone timeZone) { // The replaceAll is because Calcite doesn't like trailing zeroes in its fractional seconds part. String timestampString = TRAILING_ZEROS .matcher(CALCITE_TIMESTAMP_PRINTER.print(dateTime.withZone(timeZone))).replaceAll(""); return new TimestampString(timestampString); }
From source file:org.apache.druid.sql.calcite.planner.Calcites.java
License:Apache License
/** * Calcite expects TIME literals to be represented by TimeStrings in the local time zone. * * @param dateTime joda timestamp//ww w. j av a 2 s . co m * @param timeZone session time zone * * @return Calcite style Calendar, appropriate for literals */ public static TimeString jodaToCalciteTimeString(final DateTime dateTime, final DateTimeZone timeZone) { // The replaceAll is because Calcite doesn't like trailing zeroes in its fractional seconds part. String timeString = TRAILING_ZEROS.matcher(CALCITE_TIME_PRINTER.print(dateTime.withZone(timeZone))) .replaceAll(""); return new TimeString(timeString); }