List of usage examples for org.joda.time.format DateTimeFormatterBuilder toFormatter
public DateTimeFormatter toFormatter()
From source file:JodaDT.java
License:Open Source License
/** * Creates a DateTime object from a String with this format * DD/MM/YYYY-hh:mm:ss./*from w w w . j a va 2s .com*/ * * @param date with format DD/MM/YYYY-hh:mm:ss * @return a DateTime object or null */ public static DateTime parseDDMMYYYYhhmmss(String date) { if (date != null) { DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder(); dtfb.appendDayOfMonth(2); dtfb.appendLiteral('/'); dtfb.appendMonthOfYear(2); dtfb.appendLiteral('/'); dtfb.appendYear(4, 4); dtfb.appendLiteral('-'); dtfb.appendHourOfDay(2); dtfb.appendLiteral(':'); dtfb.appendMinuteOfHour(2); dtfb.appendLiteral(':'); dtfb.appendSecondOfMinute(2); DateTimeFormatter dtf = dtfb.toFormatter(); DateTime dt = dtf.parseDateTime(date); return dt; } else { return null; } }
From source file:JodaDT.java
License:Open Source License
/** * Creates a DateTime object from a String with this format * DD/MM/YYYY-hh:mm.//from ww w. j ava 2 s . c o m * * @param date with format DD/MM/YYYY-hh:mm * @return a DateTime object or null */ public static DateTime parseDDMMYYYYhhmm(String date) { if (date != null) { DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder(); dtfb.appendDayOfMonth(2); dtfb.appendLiteral('/'); dtfb.appendMonthOfYear(2); dtfb.appendLiteral('/'); dtfb.appendYear(4, 4); dtfb.appendLiteral('-'); dtfb.appendHourOfDay(2); dtfb.appendLiteral(':'); dtfb.appendMinuteOfHour(2); DateTimeFormatter dtf = dtfb.toFormatter(); DateTime dt = dtf.parseDateTime(date); return dt; } else { return null; } }
From source file:JodaDT.java
License:Open Source License
/** * Creates a DateTime object from a String with this format DD/MM/YYYY-hh * * @param date with format DD/MM/YYYY-hh * @return a DateTime object or null/*w w w. j av a 2 s.c om*/ */ public static DateTime parseDDMMYYYYhh(String data) { if (data != null) { DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder(); dtfb.appendDayOfMonth(2); dtfb.appendLiteral('/'); dtfb.appendMonthOfYear(2); dtfb.appendLiteral('/'); dtfb.appendYear(4, 4); dtfb.appendLiteral('-'); dtfb.appendHourOfDay(2); DateTimeFormatter dtf = dtfb.toFormatter(); DateTime dt = dtf.parseDateTime(data); return dt; } else { return null; } }
From source file:JodaDT.java
License:Open Source License
/** * Creates a DateTime object from a String with this format DD/MM/YYYY * * @param date with format DD/MM/YYYY//from w w w . ja v a 2 s.co m * @return a DateTime object or null */ public static DateTime parseDDMMYYYY(String data) { if (data != null) { DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder(); dtfb.appendDayOfMonth(2); dtfb.appendLiteral('/'); dtfb.appendMonthOfYear(2); dtfb.appendLiteral('/'); dtfb.appendYear(4, 4); DateTimeFormatter dtf = dtfb.toFormatter(); DateTime dt = dtf.parseDateTime(data); return dt; } else { return null; } }
From source file:JodaDT.java
License:Open Source License
/** * Converts a DateTimeObject into a string with format DD/MM/YYYY-hh:mm:ss. * * @param dt a DateTime object/*www .j a v a 2s .co m*/ * @return the formatted String or null */ public static String formatDDMMYYYYhhmmss(DateTime dt) { if (dt != null) { DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder(); dtfb.appendDayOfMonth(2); dtfb.appendLiteral('/'); dtfb.appendMonthOfYear(2); dtfb.appendLiteral('/'); dtfb.appendYear(4, 4); dtfb.appendLiteral('-'); dtfb.appendHourOfDay(2); dtfb.appendLiteral(':'); dtfb.appendMinuteOfHour(2); dtfb.appendLiteral(':'); dtfb.appendSecondOfMinute(2); DateTimeFormatter dtf = dtfb.toFormatter(); String str = dt.toString(dtf); return str; } else { return null; } }
From source file:JodaDT.java
License:Open Source License
/** * Converts a DateTimeObject into a string with format DD/MM/YYYY-hh:mm. * * @param dt a DateTime object/* ww w. j a va 2s .c om*/ * @return the formatted String or null */ public static String formatDDMMYYYYhhmm(DateTime dt) { if (dt != null) { DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder(); dtfb.appendDayOfMonth(2); dtfb.appendLiteral('/'); dtfb.appendMonthOfYear(2); dtfb.appendLiteral('/'); dtfb.appendYear(4, 4); dtfb.appendLiteral('-'); dtfb.appendHourOfDay(2); dtfb.appendLiteral(':'); dtfb.appendMinuteOfHour(2); DateTimeFormatter dtf = dtfb.toFormatter(); String str = dt.toString(dtf); return str; } else { return null; } }
From source file:JodaDT.java
License:Open Source License
/** * Converts a DateTimeObject into a string with format DD/MM/YYYY-hh. * * @param dt a DateTime object//ww w.j a v a2 s .co m * @return the formatted String or null */ public static String formatDDMMYYYYhh(DateTime dt) { if (dt != null) { DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder(); dtfb.appendDayOfMonth(2); dtfb.appendLiteral('/'); dtfb.appendMonthOfYear(2); dtfb.appendLiteral('/'); dtfb.appendYear(4, 4); dtfb.appendLiteral('-'); dtfb.appendHourOfDay(2); DateTimeFormatter dtf = dtfb.toFormatter(); String str = dt.toString(dtf); return str; } else { return null; } }
From source file:JodaDT.java
License:Open Source License
/** * Converts a DateTimeObject into a string with format DD/MM/YYYY * * @param dt a DateTime object//www. j a va2s .com * @return the formatted String or null */ public static String formatDDMMYYYY(DateTime dt) { if (dt != null) { DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder(); dtfb.appendDayOfMonth(2); dtfb.appendLiteral('/'); dtfb.appendMonthOfYear(2); dtfb.appendLiteral('/'); dtfb.appendYear(4, 4); DateTimeFormatter dtf = dtfb.toFormatter(); String str = dt.toString(dtf); return str; } else { return null; } }
From source file:ch.eitchnet.android.util.JodaHelper.java
License:Open Source License
/** * @param timestamp// w w w . ja va 2 s .c om * @return */ public static String toHourMinute(ReadablePartial timestamp) { DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder(); builder.appendHourOfDay(2).appendLiteral(":").appendMinuteOfHour(2); return builder.toFormatter().print(timestamp); }
From source file:ch.eitchnet.android.util.JodaHelper.java
License:Open Source License
/** * @param timestamp/*from w w w.j a va 2 s.c o m*/ * @return */ public static String toDateHourMinute(ReadablePartial timestamp) { DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder(); builder.appendYear(4, 4).appendLiteral("-").appendMonthOfYear(2).appendLiteral("-").appendDayOfMonth(2); builder.appendLiteral(" ").appendHourOfDay(2).appendLiteral(":").appendMinuteOfHour(2); return builder.toFormatter().print(timestamp); }