List of usage examples for org.joda.time DateTimeZone getDefault
public static DateTimeZone getDefault()
From source file:org.opencastproject.scheduler.impl.SchedulerServiceImpl.java
License:Educational Community License
/** * Determine the cutoff date to remove recordings in GMT * * @param buffer/*from w ww . j a v a 2 s . c o m*/ * The number of seconds before now to start the cutoff date * @return A date that is the number of seconds in buffer before now in GMT. */ public static org.joda.time.DateTime getCutoffDate(long buffer) { return getCutoffDate(buffer, new org.joda.time.DateTime(DateTimeZone.getDefault())); }
From source file:org.openhab.binding.plugwise.internal.Energy.java
License:Open Source License
public Energy(String logdate, long l, int interval) { if (logdate.length() == 8) { if (!logdate.equals("FFFFFFFF")) { int year = 0; int month = 0; long minutes = 0; year = Integer.parseInt(StringUtils.left(logdate, 2), 16) + 2000; month = Integer.parseInt(StringUtils.mid(logdate, 2, 2), 16); minutes = Long.parseLong(StringUtils.right(logdate, 4), 16); time = new DateTime(year, month, 1, 0, 0, DateTimeZone.UTC).plusMinutes((int) minutes) .toDateTime(DateTimeZone.getDefault()).minusHours(1); } else {//from w w w . j a v a 2 s. co m time = DateTime.now(); this.interval = interval; this.pulses = 0; } } else { time = DateTime.now(); } this.interval = interval; this.pulses = l; }
From source file:org.openhab.binding.plugwise.protocol.RealTimeClockGetResponseMessage.java
License:Open Source License
public DateTime getTime() { return new DateTime(year, month, day, hour, minutes, seconds, DateTimeZone.UTC) .toDateTime(DateTimeZone.getDefault()); }
From source file:org.opensaml.saml.metadata.resolver.impl.AbstractReloadingMetadataResolver.java
License:Open Source License
/** * Refreshes the metadata from its source. * // w ww . j a v a 2 s . co m * @throws ResolverException thrown is there is a problem retrieving and processing the metadata */ @Override public synchronized void refresh() throws ResolverException { DateTime now = new DateTime(ISOChronology.getInstanceUTC()); String mdId = getMetadataIdentifier(); log.debug("Beginning refresh of metadata from '{}'", mdId); try { byte[] mdBytes = fetchMetadata(); if (mdBytes == null) { log.debug("Metadata from '{}' has not changed since last refresh", mdId); processCachedMetadata(mdId, now); } else { log.debug("Processing new metadata from '{}'", mdId); processNewMetadata(mdId, now, mdBytes); } } catch (Throwable t) { log.error("Error occurred while attempting to refresh metadata from '" + mdId + "'", t); nextRefresh = new DateTime(ISOChronology.getInstanceUTC()).plus(minRefreshDelay); if (t instanceof Exception) { throw new ResolverException((Exception) t); } else { throw new ResolverException(String.format("Saw an error of type '%s' with message '%s'", t.getClass().getName(), t.getMessage())); } } finally { refreshMetadataTask = new RefreshMetadataTask(); long nextRefreshDelay = nextRefresh.getMillis() - System.currentTimeMillis(); taskTimer.schedule(refreshMetadataTask, nextRefreshDelay); log.info("Next refresh cycle for metadata provider '{}' will occur on '{}' ('{}' local time)", new Object[] { mdId, nextRefresh, nextRefresh.toDateTime(DateTimeZone.getDefault()), }); lastRefresh = now; } }
From source file:org.opensaml.saml2.metadata.provider.AbstractReloadingMetadataProvider.java
License:Open Source License
/** * Refreshes the metadata from its source. * //from w w w .java 2 s. c o m * @throws MetadataProviderException thrown is there is a problem retrieving and processing the metadata */ public synchronized void refresh() throws MetadataProviderException { DateTime now = new DateTime(ISOChronology.getInstanceUTC()); String mdId = getMetadataIdentifier(); log.debug("Beginning refresh of metadata from '{}'", mdId); try { byte[] mdBytes = fetchMetadata(); if (mdBytes == null) { log.debug("Metadata from '{}' has not changed since last refresh", mdId); processCachedMetadata(mdId, now); } else { log.debug("Processing new metadata from '{}'", mdId); processNewMetadata(mdId, now, mdBytes); } } catch (Throwable t) { log.debug("Error occurred while attempting to refresh metadata from '" + mdId + "'", t); nextRefresh = new DateTime(ISOChronology.getInstanceUTC()).plus(minRefreshDelay); if (t instanceof Exception) { throw new MetadataProviderException((Exception) t); } else { throw new MetadataProviderException(String.format("Saw an error of type '%s' with message '%s'", t.getClass().getName(), t.getMessage())); } } finally { refresMetadataTask = new RefreshMetadataTask(); long nextRefreshDelay = nextRefresh.getMillis() - System.currentTimeMillis(); taskTimer.schedule(refresMetadataTask, nextRefreshDelay); log.info("Next refresh cycle for metadata provider '{}' will occur on '{}' ('{}' local time)", new Object[] { mdId, nextRefresh, nextRefresh.toDateTime(DateTimeZone.getDefault()), }); lastRefresh = now; } }
From source file:org.renjin.primitives.time.Time.java
License:Open Source License
/** * Formats a Posix-lt time as a string.//from w w w .j a v a 2s . c o m */ @Internal("format.POSIXlt") public static StringVector formatPOSIXlt(ListVector x, StringVector patterns, boolean useTz) { PosixLtVector dateTimes = new PosixLtVector(x); List<DateTimeFormatter> formatters = DateTimeFormat.forPatterns(patterns, DateTimeZone.getDefault(), useTz); StringVector.Builder result = new StringVector.Builder(); int resultLength = Math.max(dateTimes.length(), patterns.length()); for (int i = 0; i != resultLength; ++i) { DateTimeFormatter formatter = formatters.get(i % formatters.size()); DateTime dateTime = dateTimes.getElementAsDateTime(i % dateTimes.length()); result.add(formatter.print(dateTime)); } return result.build(); }
From source file:org.renjin.primitives.time.Time.java
License:Open Source License
/** * Creates a Joda {@link DateTimeZone} instance from an R timezone string. *//*from w w w.j a v a 2 s . c o m*/ public static DateTimeZone timeZoneFromRSpecification(String tz) { if (Strings.isNullOrEmpty(tz)) { return DateTimeZone.getDefault(); } else if ("GMT".equals(tz)) { return DateTimeZone.UTC; } else { // TODO: this probably isn't right.. return DateTimeZone.forID(tz); } }
From source file:org.renjin.primitives.time.Time.java
License:Open Source License
/** * Creates a Joda {@link DateTimeZone} instance from the {@code tzone} * attribute of an R Posix object. Returns the current timezone if * there is no {@code tzone} attribute;//from w ww. j a v a 2 s .c o m */ public static DateTimeZone timeZoneFromPosixObject(SEXP lt) { SEXP attribute = lt.getAttribute(Symbols.TZONE); if (attribute instanceof StringVector) { return timeZoneFromRSpecification(((StringVector) attribute).getElementAsString(0)); } else { return DateTimeZone.getDefault(); } }
From source file:org.smallmind.nutsnbolts.mysql.UTC.java
License:Open Source License
public static Date local(Date date) { return local(date, DateTimeZone.getDefault().getOffset(System.currentTimeMillis()) / 1000 / 60); }
From source file:org.unitime.timetable.server.ServerTimeZoneBackend.java
License:Open Source License
@Override public ServerTimeZoneResponse execute(ServerTimeZoneRequest request, SessionContext context) { Date first = null, last = null; for (Session session : SessionDAO.getInstance().findAll()) { if (first == null || first.after(session.getEventBeginDate())) first = session.getEventBeginDate(); if (last == null || last.before(session.getEventEndDate())) last = session.getEventEndDate(); }//from ww w. j a va 2s. c o m DateTimeZone zone = DateTimeZone.getDefault(); int offsetInMinutes = zone.getOffset(first.getTime()) / 60000; ServerTimeZoneResponse ret = new ServerTimeZoneResponse(); ret.setId(zone.getID()); ret.addName(zone.getName(new Date().getTime())); ret.setTimeZoneOffsetInMinutes(offsetInMinutes); long time = first.getTime(); long transition; while (time != (transition = zone.nextTransition(time)) && time < last.getTime()) { int adjustment = (zone.getOffset(transition) / 60000) - offsetInMinutes; ret.addTransition((int) (transition / 3600000), adjustment); time = transition; } return ret; }