/** * <p>Returns a <code>DateFormat</code> for the specified <i>pattern</i> * and/or <code>Locale</code>.</p> * * @param pattern The pattern used to validate the value against or * <code>null</code> to use the default for the <code>Locale</code>. * @param locale The locale to use for the currency format, system default if null. * @return The <code>DateFormat</code> to created. */ @Override protected Format getFormat(String pattern, Locale locale) { DateFormat formatter = null; boolean usePattern = (pattern != null && pattern.length() > 0); if (!usePattern) { formatter = (DateFormat)getFormat(locale); } else if (locale == null) { formatter = new SimpleDateFormat(pattern); } else { DateFormatSymbols symbols = new DateFormatSymbols(locale); formatter = new SimpleDateFormat(pattern, symbols); } formatter.setLenient(false); return 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); }
/** * <p>Checks if the value is valid against a specified pattern.</p> * * @param value The value validation is being performed on. * @param pattern The pattern used to validate the value against, or the * default for the <code>Locale</code> if <code>null</code>. * @param locale The locale to use for the date format, system default if null. * @param timeZone The Time Zone used to parse the date, system default if null. * @return The parsed value if valid or <code>null</code> if invalid. */ protected Object parse(String value, String pattern, Locale locale, TimeZone timeZone) { value = (value == null ? null : value.trim()); if (value == null || value.length() == 0) { return null; } DateFormat formatter = (DateFormat)getFormat(pattern, locale); if (timeZone != null) { formatter.setTimeZone(timeZone); } return parse(value, formatter); }
/** * <p>Returns a <code>DateFormat</code> for the specified <i>pattern</i> * and/or <code>Locale</code>.</p> * * @param pattern The pattern used to validate the value against or * <code>null</code> to use the default for the <code>Locale</code>. * @param locale The locale to use for the currency format, system default if null. * @return The <code>DateFormat</code> to created. */ protected Format getFormat(String pattern, Locale locale) { DateFormat formatter = null; boolean usePattern = (pattern != null && pattern.length() > 0); if (!usePattern) { formatter = (DateFormat)getFormat(locale); } else if (locale == null) { formatter = new SimpleDateFormat(pattern); } else { DateFormatSymbols symbols = new DateFormatSymbols(locale); formatter = new SimpleDateFormat(pattern, symbols); } formatter.setLenient(false); return formatter; }
/** * <p>Returns a <code>DateFormat</code> for the specified <i>pattern</i> * and/or <code>Locale</code>.</p> * * @param pattern The pattern used to validate the value against or * <code>null</code> to use the default for the <code>Locale</code>. * @param locale The locale to use for the currency format, system default if null. * @return The <code>DateFormat</code> to created. */ @Override protected Format getFormat(String pattern, Locale locale) { DateFormat formatter = null; boolean usePattern = (pattern != null && pattern.length() > 0); if (!usePattern) { formatter = (DateFormat)getFormat(locale); } else if (locale == null) { formatter = new SimpleDateFormat(pattern); } else { DateFormatSymbols symbols = new DateFormatSymbols(locale); formatter = new SimpleDateFormat(pattern, symbols); } formatter.setLenient(false); return formatter; }
/** * <p>Returns a <code>DateFormat</code> for the specified <i>pattern</i> * and/or <code>Locale</code>.</p> * * @param pattern The pattern used to validate the value against or * <code>null</code> to use the default for the <code>Locale</code>. * @param locale The locale to use for the currency format, system default if null. * @return The <code>DateFormat</code> to created. */ @Override protected Format getFormat(String pattern, Locale locale) { DateFormat formatter = null; boolean usePattern = (pattern != null && pattern.length() > 0); if (!usePattern) { formatter = (DateFormat)getFormat(locale); } else if (locale == null) { formatter = new SimpleDateFormat(pattern); } else { DateFormatSymbols symbols = new DateFormatSymbols(locale); formatter = new SimpleDateFormat(pattern, symbols); } formatter.setLenient(false); return 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); }
/** * <p>Checks if the value is valid against a specified pattern.</p> * * @param value The value validation is being performed on. * @param pattern The pattern used to validate the value against, or the * default for the <code>Locale</code> if <code>null</code>. * @param locale The locale to use for the date format, system default if null. * @param timeZone The Time Zone used to parse the date, system default if null. * @return The parsed value if valid or <code>null</code> if invalid. */ protected Object parse(String value, String pattern, Locale locale, TimeZone timeZone) { value = (value == null ? null : value.trim()); if (value == null || value.length() == 0) { return null; } DateFormat formatter = (DateFormat)getFormat(pattern, locale); if (timeZone != null) { formatter.setTimeZone(timeZone); } return parse(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); }
/** * <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>Checks if the value is valid against a specified pattern.</p> * * @param value The value validation is being performed on. * @param pattern The pattern used to validate the value against, or the * default for the <code>Locale</code> if <code>null</code>. * @param locale The locale to use for the date format, system default if null. * @param timeZone The Time Zone used to parse the date, system default if null. * @return The parsed value if valid or <code>null</code> if invalid. */ protected Object parse(String value, String pattern, Locale locale, TimeZone timeZone) { value = (value == null ? null : value.trim()); if (value == null || value.length() == 0) { return null; } DateFormat formatter = (DateFormat)getFormat(pattern, locale); if (timeZone != null) { formatter.setTimeZone(timeZone); } return parse(value, formatter); }
/** * <p>Checks if the value is valid against a specified pattern.</p> * * @param value The value validation is being performed on. * @param pattern The pattern used to validate the value against, or the * default for the <code>Locale</code> if <code>null</code>. * @param locale The locale to use for the date format, system default if null. * @param timeZone The Time Zone used to parse the date, system default if null. * @return The parsed value if valid or <code>null</code> if invalid. */ protected Object parse(String value, String pattern, Locale locale, TimeZone timeZone) { value = (value == null ? null : value.trim()); if (value == null || value.length() == 0) { return null; } DateFormat formatter = (DateFormat)getFormat(pattern, locale); if (timeZone != null) { formatter.setTimeZone(timeZone); } return parse(value, formatter); }