List of usage examples for org.joda.time.format DateTimeFormatter withZoneUTC
public DateTimeFormatter withZoneUTC()
From source file:eu.europa.ec.fisheries.uvms.plugins.naf.util.DateUtil.java
License:Open Source License
private static Date parseToUTC(String format, String dateString) { DateTimeFormatter formatter = DateTimeFormat.forPattern(format); DateTime dateTime = formatter.withZoneUTC().parseDateTime(dateString); LOG.info("JodaTime: {}", dateTime); return dateTime.toLocalDateTime().toDate(); }
From source file:org.apache.falcon.regression.core.util.TimeUtil.java
License:Apache License
public static List<String> getMinuteDatesOnEitherSide(String startOozieDate, String endOozieDate, int minuteSkip) { DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy/MM/dd/HH/mm"); formatter.withZoneUTC(); return getMinuteDatesOnEitherSide(TimeUtil.oozieDateToDate(startOozieDate), TimeUtil.oozieDateToDate(endOozieDate), minuteSkip, formatter); }
From source file:org.apache.falcon.regression.core.util.TimeUtil.java
License:Apache License
public static List<String> getMinuteDatesOnEitherSide(DateTime startDate, DateTime endDate, int minuteSkip) { DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy/MM/dd/HH/mm"); formatter.withZoneUTC(); return getMinuteDatesOnEitherSide(startDate, endDate, minuteSkip, formatter); }
From source file:org.apache.falcon.regression.core.util.TimeUtil.java
License:Apache License
/** * Convert list of dates to list of string according to the supplied format. * * @param dates list of dates/*from www .j a v a2 s . c om*/ * @param formatter formatter to be used for converting dates * @return list of strings corresponding to given dates */ public static List<String> convertDatesToString(List<DateTime> dates, DateTimeFormatter formatter) { List<String> dateString = new ArrayList<>(); formatter.withZoneUTC(); for (DateTime date : dates) { dateString.add(formatter.print(date)); } return dateString; }
From source file:org.apache.falcon.regression.core.util.TimeUtil.java
License:Apache License
public static DateTime oozieDateToDate(String time) { DateTimeFormatter fmt = OozieUtil.getOozieDateTimeFormatter(); fmt = fmt.withZoneUTC(); return fmt.parseDateTime(time); }
From source file:org.logstash.filters.parser.JodaParser.java
License:Apache License
private Instant parseAndGuessYear(DateTimeFormatter parser, String value) { // if we get here, we need to do some special handling at the time each event is handled // because things like the current year could be different, etc. DateTime dateTime;// w ww . j ava2 s . co m if (hasZone) { dateTime = parser.parseDateTime(value); } else { dateTime = parser.withZoneUTC().parseLocalDateTime(value).toDateTime(parser.getZone()); } // The time format we have has no year listed, so we'll have to guess the year. int month = dateTime.getMonthOfYear(); DateTime now = clock.read(); int eventYear; if (month == 12 && now.getMonthOfYear() == 1) { // Now is January, event is December. Assume it's from last year. eventYear = now.getYear() - 1; } else if (month == 1 && now.getMonthOfYear() == 12) { // Now is December, event is January. Assume it's from next year. eventYear = now.getYear() + 1; } else { // Otherwise, assume it's from this year. eventYear = now.getYear(); } return dateTime.withYear(eventYear).toInstant(); }