public String getTimeSortKey() { if(lastChange==null) return "-"; return Util.XS_DATETIME_FORMATTER.format(lastChange.getTime()); }
/** * <p>Formats a date/time into a specific pattern in a time zone and locale.</p> * * @param date the date to format * @param pattern the pattern to use to format the date * @param timeZone the time zone to use, may be <code>null</code> * @param locale the locale to use, may be <code>null</code> * @return the formatted date */ public static String format(Date date, String pattern, TimeZone timeZone, Locale locale) { FastDateFormat df = FastDateFormat.getInstance(pattern, timeZone, locale); return df.format(date); }
/** * <p>Gets a date formatter instance using the specified style in the * default time zone and locale.</p> * * @param style date style: FULL, LONG, MEDIUM, or SHORT * @return a localized standard date formatter * @throws IllegalArgumentException if the Locale has no date * pattern defined * @since 2.1 */ public static FastDateFormat getDateInstance(int style) { return getDateInstance(style, null, null); }
/** * <p>Gets a formatter instance using the default pattern in the * default locale.</p> * * @return a date/time formatter */ public static FastDateFormat getInstance() { return getInstance(getDefaultPattern(), null, null); }
/** * <p>Gets a formatter instance using the specified pattern in the * default locale.</p> * * @param pattern {@link java.text.SimpleDateFormat} compatible * pattern * @return a pattern based date/time formatter * @throws IllegalArgumentException if pattern is invalid */ public static FastDateFormat getInstance(String pattern) { return getInstance(pattern, null, null); }
@PropertySetter("format") public void setFormat(String format) { if (!areEqual(format = trimify(format), this.format)) { this.format = format; formatter = format == null ? FastDateFormat.getTimeInstance(FastDateFormat.SHORT) : FastDateFormat.getInstance(format); } }
@PropertySetter("format") public void setFormat(String format) { if (!areEqual(format = trimify(format), this.format)) { this.format = format; formatter = format == null ? FastDateFormat.getDateInstance(FastDateFormat.SHORT) : FastDateFormat.getInstance(format); } }
/** * <p>Gets a time formatter instance using the specified style in the * default time zone and locale.</p> * * @param style time style: FULL, LONG, MEDIUM, or SHORT * @return a localized standard time formatter * @throws IllegalArgumentException if the Locale has no time * pattern defined * @since 2.1 */ public static FastDateFormat getTimeInstance(int style) { return getTimeInstance(style, null, null); }
/** * <p>Gets a date/time formatter instance using the specified style * in the default time zone and locale.</p> * * @param dateStyle date style: FULL, LONG, MEDIUM, or SHORT * @param timeStyle time style: FULL, LONG, MEDIUM, or SHORT * @return a localized standard date/time formatter * @throws IllegalArgumentException if the Locale has no date/time * pattern defined * @since 2.1 */ public static FastDateFormat getDateTimeInstance( int dateStyle, int timeStyle) { return getDateTimeInstance(dateStyle, timeStyle, null, null); }
/** * <p>Gets a formatter instance using the specified pattern and * locale.</p> * * @param pattern {@link java.text.SimpleDateFormat} compatible * pattern * @param locale optional locale, overrides system locale * @return a pattern based date/time formatter * @throws IllegalArgumentException if pattern is invalid */ public static FastDateFormat getInstance(String pattern, Locale locale) { return getInstance(pattern, null, locale); }
/** * <p>Gets a formatter instance using the default pattern in the * default locale.</p> * * @return a date/time formatter */ public static FastDateFormat getInstance() { return getInstance(getDefaultPattern(), null, null); }
/** * Sets the format for displaying the time. * * @param format Format for displaying the time. * @see java.text.SimpleDateFormat */ @PropertySetter(value = "format", defaultValue = "HH:mm:ss", description = "Format for displaying the time.") public void setFormat(String format) { if (!areEqual(format = trimify(format), this.format)) { this.format = format; formatter = format == null ? FastDateFormat.getTimeInstance(FastDateFormat.SHORT) : FastDateFormat.getInstance(format); } }
/** * <p>Gets a time formatter instance using the specified style and * locale in the default time zone.</p> * * @param style time style: FULL, LONG, MEDIUM, or SHORT * @param locale optional locale, overrides system locale * @return a localized standard time formatter * @throws IllegalArgumentException if the Locale has no time * pattern defined * @since 2.1 */ public static FastDateFormat getTimeInstance(int style, Locale locale) { return getTimeInstance(style, null, locale); }
/** * <p>Gets a date/time formatter instance using the specified style and * locale in the default time zone.</p> * * @param dateStyle date style: FULL, LONG, MEDIUM, or SHORT * @param timeStyle time style: FULL, LONG, MEDIUM, or SHORT * @param locale optional locale, overrides system locale * @return a localized standard date/time formatter * @throws IllegalArgumentException if the Locale has no date/time * pattern defined * @since 2.1 */ public static FastDateFormat getDateTimeInstance( int dateStyle, int timeStyle, Locale locale) { return getDateTimeInstance(dateStyle, timeStyle, null, locale); }
public static String xsDate(Calendar cal) { return Util.XS_DATETIME_FORMATTER.format(cal.getTime()); }
/** * <p>Formats a calendar into a specific pattern in a time zone and locale.</p> * * @param calendar the calendar to format * @param pattern the pattern to use to format the calendar * @param timeZone the time zone to use, may be <code>null</code> * @param locale the locale to use, may be <code>null</code> * @return the formatted calendar * @see FastDateFormat#format(Calendar) * @since 2.4 */ public static String format(Calendar calendar, String pattern, TimeZone timeZone, Locale locale) { FastDateFormat df = FastDateFormat.getInstance(pattern, timeZone, locale); return df.format(calendar); }
/** * <p>Gets a formatter instance using the specified pattern and * time zone.</p> * * @param pattern {@link java.text.SimpleDateFormat} compatible * pattern * @param timeZone optional time zone, overrides time zone of * formatted date * @return a pattern based date/time formatter * @throws IllegalArgumentException if pattern is invalid */ public static FastDateFormat getInstance(String pattern, TimeZone timeZone) { return getInstance(pattern, timeZone, null); }
/** * <p>Gets a formatter instance using the default pattern in the * default locale.</p> * * @return a date/time formatter */ public static FastDateFormat getInstance() { return getInstance(getDefaultPattern(), null, null); }
/** * <p>Gets a time formatter instance using the specified style and * time zone in the default locale.</p> * * @param style time style: FULL, LONG, MEDIUM, or SHORT * @param timeZone optional time zone, overrides time zone of * formatted time * @return a localized standard time formatter * @throws IllegalArgumentException if the Locale has no time * pattern defined * @since 2.1 */ public static FastDateFormat getTimeInstance(int style, TimeZone timeZone) { return getTimeInstance(style, timeZone, null); }
/** * <p>Gets a date formatter instance using the specified style and * locale in the default time zone.</p> * * @param style date style: FULL, LONG, MEDIUM, or SHORT * @param locale optional locale, overrides system locale * @return a localized standard date formatter * @throws IllegalArgumentException if the Locale has no date * pattern defined * @since 2.1 */ public static FastDateFormat getDateInstance(int style, Locale locale) { return getDateInstance(style, null, locale); }