List of usage examples for org.joda.time DateTimeZone forOffsetMillis
public static DateTimeZone forOffsetMillis(int millisOffset)
From source file:org.openmainframe.ade.ext.os.parser.LinuxSyslog3164ParserBase.java
License:Open Source License
/** * Set the END_OF_TODAY value and time-zone values. The time-zone values are taken from the Ade * configuration properties. End_OF_TODAY value is retrieved by getting the current date-time, * adjust time-zone, add an additional day and set the time to the start of the day. * Note: These only need to be set once. * @throws AdeException/* ww w .j a v a 2 s. c o m*/ */ private static void initializeTimeZoneAndStartOfToday() throws AdeException { synchronized (LinuxSyslog3164ParserBase.class) { if (END_OF_TODAY == null) { final IAdeConfigProperties adeConfig = Ade.getAde().getConfigProperties(); final TimeZone timeZone = adeConfig.getInputTimeZone(); final TimeZone outputTimezone = adeConfig.getOutputTimeZone(); INPUT_TIME_ZONE = DateTimeZone.forOffsetMillis(timeZone.getRawOffset()); OUTPUT_TIME_ZONE = DateTimeZone.forOffsetMillis(outputTimezone.getRawOffset()); END_OF_TODAY = DateTime.now(); END_OF_TODAY = END_OF_TODAY.withZone(OUTPUT_TIME_ZONE); END_OF_TODAY = END_OF_TODAY.plusDays(1); END_OF_TODAY = END_OF_TODAY.withTimeAtStartOfDay(); } } }
From source file:org.openmainframe.ade.ext.output.ExtOutputFilenameGenerator.java
License:Open Source License
public static DateTimeZone getInputTimeZone() throws AdeException { if (s_inputDateTimeZone == null) { final TimeZone inputTimeZone = Ade.getAde().getConfigProperties().getInputTimeZone(); s_inputDateTimeZone = DateTimeZone.forOffsetMillis(inputTimeZone.getRawOffset()); }/*from w w w . j a v a 2s . c o m*/ return s_inputDateTimeZone; }
From source file:org.openmainframe.ade.ext.output.ExtOutputFilenameGenerator.java
License:Open Source License
public static DateTimeZone getOutputTimeZone() throws AdeException { if (s_outputDateTimeZone == null) { final TimeZone outputTimeZone = Ade.getAde().getConfigProperties().getOutputTimeZone(); s_outputDateTimeZone = DateTimeZone.forOffsetMillis(outputTimeZone.getRawOffset()); }//w w w. j a va 2s .c om return s_outputDateTimeZone; }
From source file:org.openmainframe.ade.ext.stats.MessageRateStats.java
License:Open Source License
/** * Retrieve the configuration parameters * @throws AdeException // w w w. ja v a 2 s.c o m */ private void getConfiguration(short numberOf10MinutesSlotsToKeep, short[] intervalSizeList) throws AdeException { final TimeZone outJavaTimeZone = Ade.getAde().getConfigProperties().getOutputTimeZone(); s_outTimeZone = DateTimeZone.forOffsetMillis(outJavaTimeZone.getRawOffset()); /* Set the number of messages to keep */ s_maxMsgToKeep = AdeExt.getAdeExt().getConfigProperties().getMsgRateMsgToKeep(); if (s_maxMsgToKeep == -1) { s_maxMsgToKeep = MAX_MESSAGE_STATS_TO_KEEP; } /* Set the report frequency */ final String reportFreqStr = AdeExt.getAdeExt().getConfigProperties().getMsgRateReportFreq(); if (reportFreqStr == null || reportFreqStr.length() == 0) { m_reportFrequency = ReportFrequency.DAYS; m_reportFrequency.setDays(10); } else if (reportFreqStr.equalsIgnoreCase(ReportFrequency.MONTHLY.name())) { m_reportFrequency = ReportFrequency.MONTHLY; } else { final int reportFreq = Integer.parseInt(reportFreqStr); m_reportFrequency = ReportFrequency.DAYS; m_reportFrequency.setDays(reportFreq); } /* Set the number of 10 minutes interval to keep */ m_numberOf10MinutesSlotsToKeep = AdeExt.getAdeExt().getConfigProperties().getMsgRate10MinSlotsToKeep(); if (m_numberOf10MinutesSlotsToKeep == -1) { m_numberOf10MinutesSlotsToKeep = numberOf10MinutesSlotsToKeep; } /* Set the subinterval list */ m_subIntervalSizeList = AdeExt.getAdeExt().getConfigProperties().getMsgRate10MinSubIntervals(); if (m_subIntervalSizeList == null) { m_subIntervalSizeList = intervalSizeList; } /* Output the trace settings */ StringBuilder bldtrace = new StringBuilder(""); for (short interval : m_subIntervalSizeList) { bldtrace.append(interval + ","); } logger.info("Tracking Message Rate for " + m_source + " for " + m_numberOf10MinutesSlotsToKeep + " ten minutes slots" + " reportFreq=" + m_reportFrequency.toString() + " maxMsgToKeep=" + s_maxMsgToKeep + " 10MinIntervals=" + bldtrace.toString()); }
From source file:org.openmainframe.ade.ext.utils.ExtDateTimeUtils.java
License:Open Source License
/** * Method to return a "normalized" version of the input Date * whose time is reset to the absolute start of that same day * (first millisecond of first second of first minute of first hour). * /*from w w w. j a v a2 s. c om*/ * @param dateInst - instance of Date * @return - instance of Date as described * @throws AdeException */ public static Date startOfDayUsingOutputTimeZone(Date dateInst) throws AdeException { if (outputTimeZone == null) { final TimeZone outputTimezone = Ade.getAde().getConfigProperties().getOutputTimeZone(); outputTimeZone = DateTimeZone.forOffsetMillis(outputTimezone.getRawOffset()); } if (dateInst == null) { throw new IllegalArgumentException(); } /* Set start of today */ DateTime startOFDay = new DateTime(dateInst); startOFDay = startOFDay.withZone(outputTimeZone); startOFDay = startOFDay.withTimeAtStartOfDay(); return startOFDay.toDate(); }
From source file:org.openmainframe.ade.ext.utils.ExtDateTimeUtils.java
License:Open Source License
/** * Method to return a "normalized" version of the input Date * whose time is reset to the absolute start of that same day * (first millisecond of first second of first minute of first hour). * /* w ww. j ava 2s. c om*/ * @param dateInst - instance of Date * @return - instance of Date as described * @throws AdeException */ public static Date endOfDayUsingOutputTimeZone(Date dateInst) throws AdeException { /* * Note: This method generates a different end of day compare to endOfDay(). * endOfDay() would generate timestamp: 10/10/2013 23:59:59 * endOfDayUsingOutputTimeZone() would generate timestampe: 10/11/2013 00:00:00 */ if (outputTimeZone == null) { final TimeZone outputTimezone = Ade.getAde().getConfigProperties().getOutputTimeZone(); outputTimeZone = DateTimeZone.forOffsetMillis(outputTimezone.getRawOffset()); } if (dateInst == null) { throw new IllegalArgumentException(); } /* Set end of today */ DateTime startOFDay = new DateTime(dateInst); startOFDay = startOFDay.withZone(outputTimeZone); startOFDay = startOFDay.plusDays(1); startOFDay = startOFDay.withTimeAtStartOfDay(); return startOFDay.toDate(); }
From source file:org.renjin.primitives.time.Time.java
License:Open Source License
private static DateTime parseIgnoreTrailingCharacters(DateTimeFormatter formatter, String text) { // this is a modified version of DateTimeFormatter.parseDateTime() that does not // throw an exception on trailing characters Chronology chronology = DateTimeUtils.getChronology(null); DateTimeParser parser = formatter.getParser(); Locale locale = null;/* w w w .j a va 2s . com*/ Integer pivotYear = null; int defaultYear = 2000; DateTimeZone timeZone = null; DateTimeParserBucket bucket = new DateTimeParserBucket(0, chronology, locale, pivotYear, defaultYear); int newPos = parser.parseInto(bucket, text, 0); if (newPos >= 0) { long millis = bucket.computeMillis(true, text); if (formatter.isOffsetParsed() && bucket.getOffsetInteger() != null) { int parsedOffset = bucket.getOffsetInteger(); DateTimeZone parsedZone = DateTimeZone.forOffsetMillis(parsedOffset); chronology = chronology.withZone(parsedZone); } else if (bucket.getZone() != null) { chronology = chronology.withZone(bucket.getZone()); } DateTime dt = new DateTime(millis, chronology); if (timeZone != null) { dt = dt.withZone(timeZone); } return dt; } throw new IllegalArgumentException(); }
From source file:org.solovyev.common.datetime.FastDateTimeZoneProvider.java
License:Apache License
@Nonnull public DateTimeZone getZone(@Nullable String id) { if (id == null) { return DateTimeZone.UTC; }/*from www. j av a 2s . co m*/ final TimeZone tz = TimeZone.getTimeZone(id); if (tz == null) { return DateTimeZone.UTC; } int rawOffset = tz.getRawOffset(); // sub-optimal. could be improved to only create a new Date every few minutes if (tz.inDaylightTime(new Date())) { rawOffset += tz.getDSTSavings(); } return DateTimeZone.forOffsetMillis(rawOffset); }
From source file:org.talend.components.netsuite.avro.converter.XMLGregorianCalendarToDateTimeConverter.java
License:Open Source License
@Override public Object convertToAvro(XMLGregorianCalendar xts) { if (xts == null) { return null; }/* w w w . ja va2 s.com*/ MutableDateTime dateTime = new MutableDateTime(); try { dateTime.setYear(xts.getYear()); dateTime.setMonthOfYear(xts.getMonth()); dateTime.setDayOfMonth(xts.getDay()); dateTime.setHourOfDay(xts.getHour()); dateTime.setMinuteOfHour(xts.getMinute()); dateTime.setSecondOfMinute(xts.getSecond()); dateTime.setMillisOfSecond(xts.getMillisecond()); DateTimeZone tz = DateTimeZone.forOffsetMillis(xts.getTimezone() * 60000); if (tz != null) { dateTime.setZoneRetainFields(tz); } return Long.valueOf(dateTime.getMillis()); } catch (IllegalArgumentException e) { throw new ComponentException(e); } }
From source file:org.whole.lang.xsd.parsers.SchemaDataTypeParsers.java
License:Open Source License
public static IDataTypeParser time() { if (timeDataTypeParser == null) { timeDataTypeParser = new AbstractISO8601DataTypeParser(timeFormatter()) { protected Object parseWithTimeZone(DateTimeParserBucket bucket) { DateTimeZone zone = DateTimeZone.forOffsetMillis(bucket.getOffset()); return new DateTime(bucket.computeMillis(), validate(zone)); }//from w w w. ja va2 s . com protected Object parseWithoutTimeZone(DateTimeParserBucket bucket) { return new LocalTime(bucket.computeMillis()); } }; } return timeDataTypeParser; }