List of usage examples for org.joda.time.format DateTimeFormat forPattern
public static DateTimeFormatter forPattern(String pattern)
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Gets the current time stamp for zone. * //from w w w .j a v a 2 s .c o m * @param timeZone the time zone * @param pattern the pattern * @return the current time stamp for zone */ public static String getCurrentTimeStampForZone(String timeZone, String pattern) { DateTime startDate = new DateTime(DateTimeZone.forID(timeZone)); DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); return fmt.print(startDate); }
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Format./*from ww w. j a va 2 s . c o m*/ * * @param calendar the calendar * @param pattern the pattern * @return the string */ public static String format(Calendar calendar, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); return fmt.print(new DateTime(calendar)); }
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Format to utc./*www . j av a 2 s.co 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 ww. j a v a 2s. co 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.//from w w w . j av a 2 s . c o m * * @param date the date * @param pattern the pattern * @return the string */ public static String format(Date date, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); 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 w w w . j a v a 2 s. 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
/** * Format to zone./*from www .jav a 2 s . co m*/ * * @param milliseconds the milliseconds * @param zone the zone * @param pattern the pattern * @return the string */ public static String formatToZone(Long milliseconds, DateTimeZone zone, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); fmt = fmt.withZone(zone); 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 w w . j a 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 ww w . j ava2 s . c o m*/ * * @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 . j a v a 2 s . c o m*/ * * @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(); }