/** * Constructs a new {@code SimpleDateFormat} using the specified non-localized pattern and the * {@code DateFormatSymbols} and {@code Calendar} for the specified locale. * * @param template the pattern. * @param locale the locale. * @throws NullPointerException if the pattern is {@code null}. * @throws IllegalArgumentException if the pattern is invalid. */ public SimpleDateFormat(String template, Locale locale) { this(locale); validatePattern(template); pattern = template; formatData = new DateFormatSymbols(locale); }
/** * Changes the pattern of this simple date format to the specified pattern which uses * non-localized pattern characters. * * @param template the non-localized pattern. * @throws NullPointerException if the pattern is {@code null}. * @throws IllegalArgumentException if the pattern is invalid. */ public void applyPattern(String template) { validatePattern(template); pattern = template; }
/** * Constructs a new {@code SimpleDateFormat} using the specified non-localized pattern and {@code * DateFormatSymbols} and the {@code Calendar} for the user's default locale. See "<a * href="../util/Locale.html#default_locale">Be wary of the default locale</a>". * * @param template the pattern. * @param value the DateFormatSymbols. * @throws NullPointerException if the pattern is {@code null}. * @throws IllegalArgumentException if the pattern is invalid. */ public SimpleDateFormat(String template, DateFormatSymbols value) { this(Locale.getDefault()); validatePattern(template); pattern = template; formatData = (DateFormatSymbols) value.clone(); }