List of usage examples for org.joda.time.format DateTimeFormatter withZoneUTC
public DateTimeFormatter withZoneUTC()
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Gets the calendar./*w ww . j a v a2s . com*/ * * @param startTime the start time * @param minutes the minutes * @param pattern the pattern * @return the calendar */ public static Calendar getCalendar(Calendar startTime, int minutes, final String pattern) { Calendar endTime = null; DateTime start = new DateTime(startTime); DateTime end = start.plusMinutes(minutes); DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); fmt = fmt.withZoneUTC(); endTime = parseToUTCCalendar(fmt.print(end), pattern); return endTime; }
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Format to utc.//from ww w . j a v a 2 s .c o m * * @param calendar the calendar * @param pattern the pattern * @return the string */ public static String formatToUTC(Calendar calendar, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); fmt = fmt.withZoneUTC(); String strDate = fmt.print(new DateTime(calendar)); return strDate; }
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Format to utc.//w w w. j ava 2 s . c o m * * @param date the date * @param pattern the pattern * @return the string */ public static String formatToUTC(Date date, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); fmt = fmt.withZoneUTC(); String strDate = fmt.print(new DateTime(date)); return strDate; }
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Format to utc.//from www . j a va2s . com * * @param milliseconds the milliseconds * @param pattern the pattern * @return the string */ public static String formatToUTC(Long milliseconds, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); fmt = fmt.withZoneUTC(); String strDate = fmt.print(new DateTime(milliseconds)); return strDate; }
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Parses the to utc calendar.// w ww . ja v a 2 s. co m * * @param timestamp the timestamp * @param pattern the pattern * @return the calendar */ public static Calendar parseToUTCCalendar(String timestamp, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); fmt = fmt.withZoneUTC(); DateTime dt = fmt.parseDateTime(timestamp); dt = dt.toDateTime(DateTimeZone.UTC); return dt.toCalendar(Locale.ENGLISH); }
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Parses the to utc date./*from w w w . j ava 2 s. c om*/ * * @param timestamp the timestamp * @param pattern the pattern * @return the date */ public static Date parseToUTCDate(String timestamp, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); fmt = fmt.withZoneUTC(); Date date = fmt.parseDateTime(timestamp).toDate(); return date; }
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Parses the to utcms./* w w w .ja v a 2s . c om*/ * * @param timestamp the timestamp * @param pattern the pattern * @return the long */ public static Long parseToUTCMS(String timestamp, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); fmt = fmt.withZoneUTC(); Date date = fmt.parseDateTime(timestamp).toDate(); return date.getTime(); }
From source file:com.ecofactor.qa.automation.util.DateUtil.java
License:Open Source License
/** * Gets the calendar.//from w ww. j a v a 2s.c o m * @param startTime the start time * @param minutes the minutes * @return the calendar */ public static Calendar getCalendar(Calendar startTime, int minutes) { Calendar endTime = null; DateTime start = new DateTime(startTime); DateTime end = start.plusMinutes(minutes); DateTimeFormatter fmt = DateTimeFormat.forPattern(DATE_FMT_FULL); fmt = fmt.withZoneUTC(); endTime = parseToUTCCalendar(fmt.print(end), DATE_FMT_FULL); return endTime; }
From source file:com.ecofactor.qa.automation.util.DateUtil.java
License:Open Source License
/** * Format.// www . ja v a 2 s . com * @param calendar the calendar * @param pattern the pattern * @return the string */ public static String formatToUTC(Calendar calendar, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); fmt = fmt.withZoneUTC(); String strDate = fmt.print(new DateTime(calendar)); LOGGER.debug("UTC Timestamp " + strDate); return strDate; }
From source file:com.ecofactor.qa.automation.util.DateUtil.java
License:Open Source License
/** * Parses the to zone calendar.//from www. j a v a 2 s . c om * @param timestamp the timestamp * @param pattern the pattern * @param timeZone the time zone * @return the calendar */ public static Calendar parseToZoneCalendar(String timestamp, String pattern, String timeZone) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); fmt = fmt.withZoneUTC(); DateTime dt = fmt.parseDateTime(timestamp); dt = dt.toDateTime(DateTimeZone.forID(timeZone)); return dt.toCalendar(Locale.ENGLISH); }