public Builder timeFormatter(String formatOrConstant) { if (formatOrConstant == null || formatOrConstant.equalsIgnoreCase("NONE") || formatOrConstant.equalsIgnoreCase("FALSE")) { timeFormatter = null; } else if (formatOrConstant.length() == 0 || formatOrConstant.equalsIgnoreCase("DEFAULT")) { timeFormatter = DateTimeFormat.forPattern("HH:mm:ss.SSS"); } else if (formatOrConstant.equalsIgnoreCase("ISO8601")) { timeFormatter = ISODateTimeFormat.dateTime(); } else if (formatOrConstant.equalsIgnoreCase("SHORT")) { timeFormatter = DateTimeFormat.shortDateTime(); } else if (formatOrConstant.equalsIgnoreCase("MEDIUM")) { timeFormatter = DateTimeFormat.mediumDateTime(); } else if (formatOrConstant.equalsIgnoreCase("LONG")) { timeFormatter = DateTimeFormat.longDateTime(); } else { try { timeFormatter = DateTimeFormat.forPattern(formatOrConstant); } catch (IllegalArgumentException exp) { throw new IllegalArgumentException( "Cannot parse log date specification '" + formatOrConstant + "'." + "Must be either DEFAULT, NONE, ISO8601, SHORT, MEDIUM, LONG or a " + "format string parseable by DateTimeFormat. See " + "http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html"); } } return this; }
@Override public String toString() { return "DatedRevTag{" + "id=" + id.name() + ", tagName='" + tagName + '\'' + ", date=" + DateTimeFormat.longDateTime().print(date) + '}'; } }
@Override public String toString() { return "DatedRevTag{" + "id=" + id.name() + ", tagName='" + tagName + '\'' + ", date=" + DateTimeFormat.longDateTime().print(date) + '}'; } }
/** * Generates a DateTimeFormatter using full date pattern with the default locale or a new one * according to what language and country are provided as params. * * @param lang the language * @param country the country * @return the DateTimeFormatter generated */ public static DateTimeFormatter formatWithDefault(String lang, String country) { return (StringUtils.isNotBlank(lang)) ? DateTimeFormat.longDateTime().withLocale(DateTimeUtils.getLocaleByCountry(lang, country)) : DateTimeFormat.longDateTime().withLocale(Locale.getDefault()); }
public Builder timeFormatter(String formatOrConstant) { if (formatOrConstant == null || formatOrConstant.equalsIgnoreCase("NONE") || formatOrConstant.equalsIgnoreCase("FALSE")) { timeFormatter = null; } else if (formatOrConstant.length() == 0 || formatOrConstant.equalsIgnoreCase("DEFAULT")) { timeFormatter = DateTimeFormat.forPattern("HH:mm:ss.SSS"); } else if (formatOrConstant.equalsIgnoreCase("ISO8601")) { timeFormatter = ISODateTimeFormat.dateTime(); } else if (formatOrConstant.equalsIgnoreCase("SHORT")) { timeFormatter = DateTimeFormat.shortDateTime(); } else if (formatOrConstant.equalsIgnoreCase("MEDIUM")) { timeFormatter = DateTimeFormat.mediumDateTime(); } else if (formatOrConstant.equalsIgnoreCase("LONG")) { timeFormatter = DateTimeFormat.longDateTime(); } else { try { timeFormatter = DateTimeFormat.forPattern(formatOrConstant); } catch (IllegalArgumentException exp) { throw new IllegalArgumentException( "Cannot parse log date specification '" + formatOrConstant + "'." + "Must be either DEFAULT, NONE, ISO8601, SHORT, MEDIUM, LONG or a " + "format string parseable by DateTimeFormat. See " + "http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html"); } } return this; }
private static DateTimeFormatter getDateTimeFormatter(final String localeLang, final String localeCountry, final String timezone, final String dateFormat) { DateTimeFormatter formatter; if (StringUtilities.isNoneBlank(dateFormat)) { formatter = DateTimeFormat.forPattern(dateFormat); } else { formatter = DateTimeFormat.longDateTime(); } if (isNotBlank(timezone)) { formatter = formatter.withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone(timezone))); } if (isNotBlank(localeLang)) { formatter = formatter.withLocale(DateTimeUtils.getLocaleByCountry(localeLang, localeCountry)); } return formatter; }