List of usage examples for org.joda.time DateTime withZone
public DateTime withZone(DateTimeZone newZone)
From source file:divconq.util.TimeUtil.java
License:Open Source License
/** * Format date and time in Long format/*from ww w. j a v a 2 s . com*/ * * @param at datetime to format * @param zone which timezone to use * @param locale which locale to use * @return formatted datetime */ static public String fmtDateTimeLong(DateTime at, DateTimeZone zone, String locale) { if (at == null) return null; return TimeUtil.fmtDateTimeLong(at.withZone(zone), locale); }
From source file:divconq.util.TimeUtil.java
License:Open Source License
/** * Format date in Long format//w w w. ja v a2 s . co m * * @param at datetime to format * @param zone which timezone to use * @param locale which locale to use * @return formatted date */ static public String fmtDateLong(DateTime at, String zone, String locale) { if (at == null) return null; return TimeUtil.fmtDateLong(at.withZone(TimeUtil.selectZone(zone)), locale); }
From source file:divconq.util.TimeUtil.java
License:Open Source License
/** * Format date in Long format// w ww .j a v a 2s. c o m * * @param at datetime to format * @param zone which timezone to use * @param locale which locale to use * @return formatted date */ static public String fmtDateLong(DateTime at, DateTimeZone zone, String locale) { if (at == null) return null; return TimeUtil.fmtDateLong(at.withZone(zone), locale); }
From source file:eu.thebluemountain.customers.dctm.brownbag.badcontentslister.Content.java
License:Apache License
/** * The method that returns the content matching supplied arguments. * * @param store carries the related store's identifier * @param ticket holds the data ticket for the content * @param parent carries the parent object identifier * @param rendition indicates whether content matches a rendition * @param format carries the related format's name * @param page is the page index of the content for the format * @param extension carries the extension ... if any * @param size carries the expected size of contents * @param modified holds the modified date for the content * @return the matching content object//ww w . ja v a 2 s . co m */ public static Content create(String store, int ticket, String parent, boolean rendition, String format, int page, Optional<String> extension, int size, DateTime modified) { Preconditions.checkNotNull(store); Preconditions.checkNotNull(parent); Preconditions.checkNotNull(format); Preconditions.checkArgument(0 <= page); Preconditions.checkNotNull(extension); Preconditions.checkArgument(0 <= size); Preconditions.checkNotNull(modified); modified = modified.withZone(DateTimeZone.UTC); return new Content(store, ticket, parent, rendition, format, page, extension, size, modified); }
From source file:fi.hsl.parkandride.back.prediction.PredictionDao.java
License:EUPL
private static Path<Integer> spacesAvailableAt(DateTime timestamp) { // Also other parts of this class assume prediction resolution, // so we don't do the rounding here, but require the timestamp // to already have been properly rounded. assert timestamp.equals(toPredictionResolution(timestamp)) : "not in prediction resolution: " + timestamp; String hhmm = DateTimeFormat.forPattern("HHmm").print(timestamp.withZone(DateTimeZone.UTC)); return spacesAvailableColumnsByHHmm.get(hhmm); }
From source file:helper.JodaTimeHelper.java
public String calculateDateTime() { DateTime dt = new DateTime(); dt = dt.withZone(DateTimeZone.forID("-05:00")); DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); return fmt.print(dt); }
From source file:imas.planning.entity.FlightEntity.java
private String convertTimezone(Date date, String countryName) { DateTime original = new DateTime(date.getTime()); DateTimeZone dtz = DateTimeZone.getDefault(); original.withZone(dtz); Set<String> tzIds = DateTimeZone.getAvailableIDs(); for (String timeZoneId : tzIds) { if (timeZoneId.contains(countryName)) { dtz = DateTimeZone.forID(timeZoneId); break; }//from w w w. ja va 2 s.c om } DateTime dt = original.toDateTime(dtz); DateTimeFormatter dtfOut = DateTimeFormat.forPattern("MMM dd yyyy HH:mm:ss zzz"); return dtfOut.print(dt); }
From source file:io.druid.sql.calcite.planner.Calcites.java
License:Apache License
/** * Calcite expects "TIMESTAMP" types to be an instant that has the expected local time fields if printed as UTC. * * @param dateTime joda timestamp/* w w w . ja v a 2s . c om*/ * @param timeZone session time zone * * @return Calcite style millis */ public static long jodaToCalciteTimestamp(final DateTime dateTime, final DateTimeZone timeZone) { return dateTime.withZone(timeZone).withZoneRetainFields(DateTimeZone.UTC).getMillis(); }
From source file:io.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/*from ww w .j a v a 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(new DateTime(0L, DateTimeZone.UTC), date.withZoneRetainFields(DateTimeZone.UTC)) .getDays(); }
From source file:io.druid.sql.calcite.planner.PlannerContext.java
License:Apache License
public static PlannerContext create(final DruidOperatorTable operatorTable, final ExprMacroTable macroTable, final PlannerConfig plannerConfig, final Map<String, Object> queryContext) { final DateTime utcNow; final DateTimeZone timeZone; if (queryContext != null) { final Object tsParam = queryContext.get(CTX_SQL_CURRENT_TIMESTAMP); final Object tzParam = queryContext.get(CTX_SQL_TIME_ZONE); if (tsParam != null) { utcNow = new DateTime(tsParam, DateTimeZone.UTC); } else {// ww w .j a v a2s. c o m utcNow = new DateTime(DateTimeZone.UTC); } if (tzParam != null) { timeZone = DateTimeZone.forID(String.valueOf(tzParam)); } else { timeZone = DateTimeZone.UTC; } } else { utcNow = new DateTime(DateTimeZone.UTC); timeZone = DateTimeZone.UTC; } return new PlannerContext(operatorTable, macroTable, plannerConfig.withOverrides(queryContext), utcNow.withZone(timeZone), queryContext); }