List of usage examples for org.joda.time DateTimeZone forTimeZone
public static DateTimeZone forTimeZone(TimeZone zone)
From source file:org.egov.infra.config.core.LocalizationSettings.java
License:Open Source License
public static DateTimeZone jodaTimeZone() { return DateTimeZone.forTimeZone(timeZone()); }
From source file:org.elasticsearch.test.ESIntegTestCase.java
License:Apache License
/** * Returns a random JODA Time Zone based on Java Time Zones *//* w ww . j a v a 2 s .c om*/ public static DateTimeZone randomDateTimeZone() { DateTimeZone timeZone; // It sounds like some Java Time Zones are unknown by JODA. For example: Asia/Riyadh88 // We need to fallback in that case to a known time zone try { timeZone = DateTimeZone.forTimeZone(RandomizedTest.randomTimeZone()); } catch (IllegalArgumentException e) { timeZone = DateTimeZone.forOffsetHours(randomIntBetween(-12, 12)); } return timeZone; }
From source file:org.elasticsearch.xpack.sql.execution.search.extractor.CompositeKeyExtractor.java
License:Open Source License
@Override public void writeTo(StreamOutput out) throws IOException { out.writeString(key);//from w w w. jav a 2s.co m out.writeEnum(property); if (out.getVersion().onOrAfter(Version.V_6_3_0)) { if (timeZone == null) { out.writeBoolean(false); } else { out.writeBoolean(true); out.writeString(timeZone.getID()); } } else { out.writeOptionalTimeZone(timeZone == null ? null : DateTimeZone.forTimeZone(timeZone)); } }
From source file:org.elasticsearch.xpack.sql.execution.search.extractor.CompositeKeyExtractor.java
License:Open Source License
@Override public Object extract(Bucket bucket) { if (property == Property.COUNT) { return bucket.getDocCount(); }// ww w .jav a 2 s . c o m // get the composite value Object m = bucket.getKey(); if (!(m instanceof Map)) { throw new SqlIllegalArgumentException("Unexpected bucket returned: {}", m); } Object object = ((Map<?, ?>) m).get(key); if (timeZone != null) { if (object instanceof Long) { object = new DateTime(((Long) object).longValue(), DateTimeZone.forTimeZone(timeZone)); } else { throw new SqlIllegalArgumentException("Invalid date key returned: {}", object); } } return object; }
From source file:org.elasticsearch.xpack.sql.expression.function.scalar.datetime.DateTimeProcessor.java
License:Open Source License
@Override public Object process(Object l) { if (l == null) { return null; }//from w w w. ja v a2s . c o m ReadableDateTime dt; if (l instanceof String) { // 6.4+ final long millis = Long.parseLong(l.toString()); dt = new DateTime(millis, DateTimeZone.forTimeZone(timeZone)); } else if (l instanceof ReadableInstant) { // 6.3- dt = (ReadableDateTime) l; if (!TimeZone.getTimeZone("UTC").equals(timeZone)) { dt = dt.toDateTime().withZone(DateTimeZone.forTimeZone(timeZone)); } } else { throw new SqlIllegalArgumentException("A string or a date is required; received {}", l); } return extractor.extract(dt); }
From source file:org.elasticsearch.xpack.sql.querydsl.agg.GroupByDateKey.java
License:Open Source License
@Override public DateHistogramValuesSourceBuilder asValueSource() { return new DateHistogramValuesSourceBuilder(id()).field(fieldName()) .dateHistogramInterval(new DateHistogramInterval(interval)) .timeZone(DateTimeZone.forTimeZone(timeZone)); }
From source file:org.everit.jira.core.util.TimetrackerUtil.java
License:Apache License
/** * Get the logged user {@link DateTimeZone}. * * @return The logged user {@link DateTimeZone}. *///from w ww . j ava2 s . c o m public static DateTimeZone getLoggedUserTimeZone() { TimeTrackerSettingsHelper settingsHelper = ComponentAccessor .getOSGiComponentInstanceOfType(TimeTrackerSettingsHelper.class); TimeTrackerGlobalSettings globalSettings = settingsHelper.loadGlobalSettings(); TimeZoneTypes timeZoneTypes = globalSettings.getTimeZone(); if (TimeZoneTypes.USER.equals(timeZoneTypes)) { TimeZoneServiceImpl timeZoneServiceImpl = TimetrackerUtil.getInitializedTimeZoneServeice(); JiraServiceContext serviceContext = TimetrackerUtil.getServiceContext(); TimeZone timeZone = timeZoneServiceImpl.getUserTimeZone(serviceContext); return DateTimeZone.forTimeZone(timeZone); } else { return TimetrackerUtil.getSystemTimeZone(); } }
From source file:org.everit.jira.core.util.TimetrackerUtil.java
License:Apache License
/** * Get the system {@link DateTimeZone}./* w w w. java 2 s . c om*/ * * @return The system {@link DateTimeZone}. */ public static DateTimeZone getSystemTimeZone() { TimeZoneServiceImpl timeZoneServiceImpl = TimetrackerUtil.getInitializedTimeZoneServeice(); JiraServiceContext serviceContext = TimetrackerUtil.getServiceContext(); TimeZone timeZone = timeZoneServiceImpl.getJVMTimeZoneInfo(serviceContext).toTimeZone(); return DateTimeZone.forTimeZone(timeZone); }
From source file:org.flockdata.model.Entity.java
License:Open Source License
public Entity(String metaKey, FortressSegment segment, @NotEmpty EntityInputBean entityInput, @NotEmpty DocumentType documentType) throws FlockException { this();/*from w w w .j av a 2 s. co m*/ assert documentType != null; assert segment != null; labels.add(documentType.getName()); this.metaKey = metaKey; this.noLogs = entityInput.isEntityOnly(); this.segment = segment;//(FortressNode)documentType.getFortress(); // DAT-278 String docType = documentType.getName(); if (docType == null) docType = documentType.getCode(); if (docType == null) throw new RuntimeException( "Unable to resolve the doc type code [" + documentType + "] for " + entityInput); newEntity = true; docType = docType.toLowerCase(); code = entityInput.getCode(); key = EntityHelper.parseKey(this.segment.getFortress().getId(), documentType.getId(), (code != null ? code : this.metaKey)); //key = this.fortress.getId() + "." + documentType.getId() + "." + (code != null ? code : metaKey); if (entityInput.getName() == null || entityInput.getName().equals("")) this.name = (code == null ? docType : (docType + "." + code)); else this.name = entityInput.getName(); this.description = entityInput.getDescription(); indexName = IndexHelper.getIndexRoot(this.segment); if (entityInput.getProperties() != null && !entityInput.getProperties().isEmpty()) { props = new DynamicPropertiesContainer(entityInput.getProperties()); } Date when = entityInput.getWhen(); if (when == null) fortressCreate = new DateTime(dateCreated, DateTimeZone.forTimeZone(TimeZone.getTimeZone(this.segment.getFortress().getTimeZone()))) .getMillis(); else fortressCreate = new DateTime(when.getTime()).getMillis();//new DateTime( when.getTime(), DateTimeZone.forTimeZone(TimeZone.getTimeZone(entityInput.getMetaTZ()))).toDate().getTime(); if (entityInput.getLastChange() != null) { long fWhen = entityInput.getLastChange().getTime(); if (fWhen != fortressCreate) fortressLastWhen = fWhen; } // Content date has the last say on when the update happened if (entityInput.getContent() != null && entityInput.getContent().getWhen() != null) { fortressLastWhen = entityInput.getContent().getWhen().getTime(); } //lastUpdate = 0l; if (entityInput.isEntityOnly()) this.event = entityInput.getEvent(); this.suppressSearch(entityInput.isSearchSuppressed()); }
From source file:org.flockdata.model.Entity.java
License:Open Source License
@JsonIgnore public DateTime getFortressCreatedTz() { return new DateTime(fortressCreate, DateTimeZone.forTimeZone(TimeZone.getTimeZone(segment.getFortress().getTimeZone()))); }