List of usage examples for org.joda.time DateTimeZone getDefault
public static DateTimeZone getDefault()
From source file:org.epics.archiverappliance.common.TimeUtils.java
public static long convertToLocalEpochMillis(long epochMillis) { if (epochMillis == 0) return 0; return epochMillis + DateTimeZone.getDefault().getOffset(epochMillis); }
From source file:org.epics.archiverappliance.common.TimeUtils.java
/** * Whether we are in DST for a particular time in the servers default timezone. * Mostly used by Matlab.//from w ww .ja v a2 s .c o m * @param ts * @return */ public static boolean isDST(Timestamp ts) { return !DateTimeZone.getDefault().isStandardOffset(ts.getTime()); }
From source file:org.fixb.quickfix.QuickFixFieldExtractor.java
License:Apache License
@SuppressWarnings("unchecked") private <T> T getFieldValueFromMap(FieldMap message, Class<T> type, int tag) { try {/*from w w w . j a va 2 s. c om*/ if (type == String.class) { return (T) message.getString(tag); } else if (type == Boolean.class || type == boolean.class) { return (T) Boolean.valueOf(message.getBoolean(tag)); } else if (type == Character.class || type == char.class) { return (T) Character.valueOf(message.getChar(tag)); } else if (type == Integer.class || type == int.class) { return (T) Integer.valueOf(message.getInt(tag)); } else if (type == Double.class || type == double.class) { return (T) Double.valueOf(message.getDouble(tag)); } else if (type == BigDecimal.class) { return (T) message.getDecimal(tag); } else if (type == Instant.class) { return (T) new Instant(message.getUtcTimeStamp(tag)); } else if (type == LocalDate.class) { String dateString = message.getString(tag); return (T) LocalDate.parse(dateString, new DateTimeFormatterBuilder().appendPattern("yyyyMMdd").toFormatter()); } else if (type == LocalTime.class) { Date utcTime = message.getUtcTimeOnly(tag); return (T) new DateTime(utcTime, DateTimeZone.getDefault()).toLocalTime(); } else if (type == LocalDateTime.class) { Date utcTime = message.getUtcTimeStamp(tag); return (T) new DateTime(utcTime, DateTimeZone.getDefault()).toLocalDateTime(); } else if (type == DateTime.class) { Date utcDate = message.getUtcTimeStamp(tag); return (T) new DateTime(utcDate, DateTimeZone.UTC); } else if (type == Date.class) { return (T) message.getUtcTimeStamp(tag); } else if (type.isEnum()) { int fieldValue = message.getInt(tag); for (T enumValue : type.getEnumConstants()) { int ordValue = ((Enum) enumValue).ordinal() + 1; if (ordValue == fieldValue) { return enumValue; } } throw new IllegalArgumentException("Invalid ordinal of enum type " + type + ": " + fieldValue); } else { throw new IllegalArgumentException("Can't map type to FIX type: " + type); } } catch (FieldNotFound e) { return null; } catch (FieldException e) { throw new FixException(e); } }
From source file:org.forgerock.openidm.util.DateUtil.java
License:CDDL license
/** * Creates a DateUtil using the default timezone and generates ISO8601 * timestamps. */ private DateUtil() { this(DateTimeZone.getDefault()); }
From source file:org.geant.idpextension.oidc.metadata.impl.AbstractReloadingOIDCEntityResolver.java
License:BSD License
/** * Schedules the next refresh. If the given delay is 0, then {@link maxRefreshDelay} is used. * @param delay The delay before the next refresh. *//*from ww w. j a va 2 s . c om*/ protected void scheduleNextRefresh(final long delay) { refreshMetadataTask = new RefreshMetadataTask(); long refreshDelay = delay; if (delay == 0) { refreshDelay = maxRefreshDelay; } nextRefresh = new DateTime(ISOChronology.getInstanceUTC()).plus(refreshDelay); final 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[] { getMetadataIdentifier(), nextRefresh, nextRefresh.toDateTime(DateTimeZone.getDefault()), }); }
From source file:org.gradle.performance.fixture.GCEventParser.java
License:Apache License
GCEvent parseLine(String line) { if (line.trim().isEmpty()) { return GCEvent.IGNORED; }// w w w.jav a2 s.c o m Matcher matcher = pattern.matcher(line); if (!matcher.lookingAt()) { if (ignorePattern.matcher(line).matches()) { //I see this kind of events on windows. Let's see if this approach helps resolving them. return GCEvent.IGNORED; } else { notParsed.add(line); return GCEvent.IGNORED; } } try { DateTime timestamp = DateTime.parse(matcher.group(1)); // Some JVMs generate an incorrect timezone offset in the timestamps. Discard timezone and use the local timezone instead timestamp = timestamp.toLocalDateTime().toDateTime(DateTimeZone.getDefault()); long start = Long.parseLong(matcher.group(2)); long end = Long.parseLong(matcher.group(3)); long committed = Long.parseLong(matcher.group(4)); return new GCEvent(start, end, committed, timestamp); } catch (Exception ex) { notParsed.add(line); return GCEvent.IGNORED; } }
From source file:org.graylog2.plugin.ServerStatus.java
License:Open Source License
public DateTimeZone getTimezone() { return DateTimeZone.getDefault(); }
From source file:org.jadira.usertype.dateandtime.joda.util.ZoneHelper.java
License:Apache License
public static DateTimeZone getDefault() { return DateTimeZone.getDefault(); }
From source file:org.jasig.portlet.blackboardvcportlet.dao.impl.ServerConfigurationDaoImpl.java
License:Apache License
@Override @Transactional//from w w w .ja va2 s . c om public ServerConfigurationImpl createOrUpdateConfiguration( BlackboardServerConfigurationResponse configurationResponse) { ServerConfigurationImpl serverConfiguration = this.getServerConfiguration(); if (serverConfiguration == null) { serverConfiguration = new ServerConfigurationImpl(); } serverConfiguration.onUpdate(); if (serverConfiguration.getRandomCallbackUrl() == null) { //Create random callback URL for blackboard callback serverConfiguration.setRandomCallbackUrl(RandomStringUtils.randomAlphanumeric(20)); } serverConfiguration.setBoundaryTime(configurationResponse.getBoundaryTime()); serverConfiguration.setMaxAvailableTalkers(configurationResponse.getMaxAvailableTalkers()); serverConfiguration.setMaxAvailableCameras(configurationResponse.getMaxAvailableCameras()); serverConfiguration.setRaiseHandOnEnter(configurationResponse.isRaiseHandOnEnter()); serverConfiguration.setMayUseTelephony(configurationResponse.isMayUseTelephony()); serverConfiguration.setMayUseSecureSignOn(configurationResponse.isMayUseSecureSignOn()); serverConfiguration.setMustReserveSeats(configurationResponse.isMustReserveSeats()); final String timeZoneStr = configurationResponse.getTimeZone(); final Matcher tzMatcher = DATE_TZ_PATTERN.matcher(timeZoneStr); if (tzMatcher.matches()) { int hours = Integer.parseInt(tzMatcher.group(1)); int minutes = Integer.parseInt(tzMatcher.group(2)); final DateTimeZone tz = DateTimeZone.forOffsetHoursMinutes(hours, minutes); serverConfiguration.setTimezone(tz); logger.debug("Parsed timezone string '{}' to {}", timeZoneStr, tz); } else { final DateTimeZone tz = DateTimeZone.getDefault(); serverConfiguration.setTimezone(tz); logger.warn("Failed to parse timezone string '{}' defaulting to {}", timeZoneStr, tz); } this.getEntityManager().persist(serverConfiguration); return serverConfiguration; }
From source file:org.jboss.seam.international.datetimezone.DefaultDateTimeZoneProducer.java
License:Apache License
@PostConstruct public void init() { if (!defaultTimeZoneId.isUnsatisfied()) { try {//from w ww.j ava2 s .co m String id = defaultTimeZoneId.get(); DateTimeZone dtz = DateTimeZone.forID(id); defaultDateTimeZone = constructTimeZone(dtz); } catch (IllegalArgumentException e) { log.warn("DefaultDateTimeZoneProducer: Default TimeZone Id of " + defaultTimeZoneId + " was not found"); } } if (null == defaultDateTimeZone) { DateTimeZone dtz = DateTimeZone.getDefault(); defaultDateTimeZone = constructTimeZone(dtz); } }