/** * <p>Format an object into a <code>String</code> using * the default Locale.</p> * * @param value The value validation is being performed on. * @param timeZone The Time Zone used to format the date, * system default if null (unless value is a <code>Calendar</code>. * @return The value formatted as a <code>String</code>. */ public String format(Object value, TimeZone timeZone) { return format(value, (String)null, (Locale)null, timeZone); }
/** * <p>Format an object using the specified pattern and/or * <code>Locale</code>. * * @param value The value validation is being performed on. * @param pattern The pattern used to format the value. * @param locale The locale to use for the Format. * @return The value formatted as a <code>String</code>. */ @Override public String format(Object value, String pattern, Locale locale) { return format(value, pattern, locale, (TimeZone)null); }
/** * <p>Format an object into a <code>String</code> using * the specified pattern.</p> * * @param value The value validation is being performed on. * @param pattern The pattern used to format the value. * @param timeZone The Time Zone used to format the date, * system default if null (unless value is a <code>Calendar</code>. * @return The value formatted as a <code>String</code>. */ public String format(Object value, String pattern, TimeZone timeZone) { return format(value, pattern, (Locale)null, timeZone); }
/** * <p>Format an object into a <code>String</code> using * the specified Locale.</p> * * @param value The value validation is being performed on. * @param locale The locale to use for the Format. * @param timeZone The Time Zone used to format the date, * system default if null (unless value is a <code>Calendar</code>. * @return The value formatted as a <code>String</code>. */ public String format(Object value, Locale locale, TimeZone timeZone) { return format(value, (String)null, locale, timeZone); }
/** * <p>Format an object using the specified pattern and/or * <code>Locale</code>. * * @param value The value validation is being performed on. * @param pattern The pattern used to format the value. * @param locale The locale to use for the Format. * @param timeZone The Time Zone used to format the date, * system default if null (unless value is a <code>Calendar</code>. * @return The value formatted as a <code>String</code>. */ public String format(Object value, String pattern, Locale locale, TimeZone timeZone) { DateFormat formatter = (DateFormat)getFormat(pattern, locale); if (timeZone != null) { formatter.setTimeZone(timeZone); } else if (value instanceof Calendar) { formatter.setTimeZone(((Calendar)value).getTimeZone()); } return format(value, formatter); }
/** * Test Invalid Dates with "locale" validation */ public void testFormat() { // Create a Date or Calendar Object test = validator.parse("2005-11-28", "yyyy-MM-dd", null, null); assertNotNull("Test Date ", test); assertEquals("Format pattern", "28.11.05", validator.format(test, "dd.MM.yy")); assertEquals("Format locale", "11/28/05", validator.format(test, Locale.US)); }
/** * <p>Format an object into a <code>String</code> using * the default Locale.</p> * * @param value The value validation is being performed on. * @param timeZone The Time Zone used to format the date, * system default if null (unless value is a <code>Calendar</code>. * @return The value formatted as a <code>String</code>. */ public String format(Object value, TimeZone timeZone) { return format(value, (String)null, (Locale)null, timeZone); }
/** * <p>Format an object into a <code>String</code> using * the default Locale.</p> * * @param value The value validation is being performed on. * @param timeZone The Time Zone used to format the date, * system default if null (unless value is a <code>Calendar</code>. * @return The value formatted as a <code>String</code>. */ public String format(Object value, TimeZone timeZone) { return format(value, (String)null, (Locale)null, timeZone); }
/** * <p>Format an object into a <code>String</code> using * the specified Locale.</p> * * @param value The value validation is being performed on. * @param locale The locale to use for the Format. * @param timeZone The Time Zone used to format the date, * system default if null (unless value is a <code>Calendar</code>. * @return The value formatted as a <code>String</code>. */ public String format(Object value, Locale locale, TimeZone timeZone) { return format(value, (String)null, locale, timeZone); }
/** * <p>Format an object using the specified pattern and/or * <code>Locale</code>. * * @param value The value validation is being performed on. * @param pattern The pattern used to format the value. * @param locale The locale to use for the Format. * @return The value formatted as a <code>String</code>. */ @Override public String format(Object value, String pattern, Locale locale) { return format(value, pattern, locale, (TimeZone)null); }
/** * <p>Format an object into a <code>String</code> using * the specified pattern.</p> * * @param value The value validation is being performed on. * @param pattern The pattern used to format the value. * @param timeZone The Time Zone used to format the date, * system default if null (unless value is a <code>Calendar</code>. * @return The value formatted as a <code>String</code>. */ public String format(Object value, String pattern, TimeZone timeZone) { return format(value, pattern, (Locale)null, timeZone); }
/** * <p>Format an object into a <code>String</code> using * the specified Locale.</p> * * @param value The value validation is being performed on. * @param locale The locale to use for the Format. * @param timeZone The Time Zone used to format the date, * system default if null (unless value is a <code>Calendar</code>. * @return The value formatted as a <code>String</code>. */ public String format(Object value, Locale locale, TimeZone timeZone) { return format(value, (String)null, locale, timeZone); }
/** * <p>Format an object into a <code>String</code> using * the specified pattern.</p> * * @param value The value validation is being performed on. * @param pattern The pattern used to format the value. * @param timeZone The Time Zone used to format the date, * system default if null (unless value is a <code>Calendar</code>. * @return The value formatted as a <code>String</code>. */ public String format(Object value, String pattern, TimeZone timeZone) { return format(value, pattern, (Locale)null, timeZone); }
/** * <p>Format an object using the specified pattern and/or * <code>Locale</code>. * * @param value The value validation is being performed on. * @param pattern The pattern used to format the value. * @param locale The locale to use for the Format. * @return The value formatted as a <code>String</code>. */ @Override public String format(Object value, String pattern, Locale locale) { return format(value, pattern, locale, (TimeZone)null); }
/** * <p>Format an object into a <code>String</code> using * the default Locale.</p> * * @param value The value validation is being performed on. * @param timeZone The Time Zone used to format the date, * system default if null (unless value is a <code>Calendar</code>. * @return The value formatted as a <code>String</code>. */ public String format(Object value, TimeZone timeZone) { return format(value, (String)null, (Locale)null, timeZone); }
/** * <p>Format an object using the specified pattern and/or * <code>Locale</code>. * * @param value The value validation is being performed on. * @param pattern The pattern used to format the value. * @param locale The locale to use for the Format. * @return The value formatted as a <code>String</code>. */ public String format(Object value, String pattern, Locale locale) { return format(value, pattern, locale, (TimeZone)null); }
/** * <p>Format an object into a <code>String</code> using * the specified pattern.</p> * * @param value The value validation is being performed on. * @param pattern The pattern used to format the value. * @param timeZone The Time Zone used to format the date, * system default if null (unless value is a <code>Calendar</code>. * @return The value formatted as a <code>String</code>. */ public String format(Object value, String pattern, TimeZone timeZone) { return format(value, pattern, (Locale)null, timeZone); }
/** * <p>Format an object into a <code>String</code> using * the specified Locale.</p> * * @param value The value validation is being performed on. * @param locale The locale to use for the Format. * @param timeZone The Time Zone used to format the date, * system default if null (unless value is a <code>Calendar</code>. * @return The value formatted as a <code>String</code>. */ public String format(Object value, Locale locale, TimeZone timeZone) { return format(value, (String)null, locale, timeZone); }
/** * <p>Format an object using the specified pattern and/or * <code>Locale</code>. * * @param value The value validation is being performed on. * @param pattern The pattern used to format the value. * @param locale The locale to use for the Format. * @param timeZone The Time Zone used to format the date, * system default if null (unless value is a <code>Calendar</code>. * @return The value formatted as a <code>String</code>. */ public String format(Object value, String pattern, Locale locale, TimeZone timeZone) { DateFormat formatter = (DateFormat)getFormat(pattern, locale); if (timeZone != null) { formatter.setTimeZone(timeZone); } else if (value instanceof Calendar) { formatter.setTimeZone(((Calendar)value).getTimeZone()); } return format(value, formatter); }
/** * <p>Format an object using the specified pattern and/or * <code>Locale</code>. * * @param value The value validation is being performed on. * @param pattern The pattern used to format the value. * @param locale The locale to use for the Format. * @param timeZone The Time Zone used to format the date, * system default if null (unless value is a <code>Calendar</code>. * @return The value formatted as a <code>String</code>. */ public String format(Object value, String pattern, Locale locale, TimeZone timeZone) { DateFormat formatter = (DateFormat)getFormat(pattern, locale); if (timeZone != null) { formatter.setTimeZone(timeZone); } else if (value instanceof Calendar) { formatter.setTimeZone(((Calendar)value).getTimeZone()); } return format(value, formatter); }