/** * Applies the given pattern string to this date format. * * @param pattern the new date and time pattern for this date format * @throws NullPointerException if the given pattern is null * @throws IllegalArgumentException if the given pattern is invalid */ @Override public void applyPattern( String pattern ) { DateFormatSymbols formatSymbols = super.getDateFormatSymbols(); init( pattern, formatSymbols, false ); }
/** * Applies the given localized pattern string to this date format. * * @param pattern a String to be mapped to the new date and time format pattern for this format * @throws NullPointerException if the given pattern is null * @throws IllegalArgumentException if the given pattern is invalid */ @Override public void applyLocalizedPattern( String pattern ) { DateFormatSymbols formatSymbols = super.getDateFormatSymbols(); init( pattern, formatSymbols, true ); }
return localSimpleDateFormat.get().getDateFormatSymbols();
/** * @return returns an array of 12 strings representing the short * month names used by this parse. */ public String[] getShortMonths() { return defaultDateFormat.getDateFormatSymbols().getShortMonths(); }
import java.util.*; import java.text.*; public class Test { public static void main(String[] args) throws Exception { String text = "2013-05-23T09:18:07 p.m..380+0000"; String pattern = "yyyy-MM-dd'T'hh:mm:ss aa'.380+0000'"; SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.US); format.setTimeZone(TimeZone.getTimeZone("UTC")); DateFormatSymbols symbols = format.getDateFormatSymbols(); symbols = (DateFormatSymbols) symbols.clone(); symbols.setAmPmStrings(new String[] { "a.m.", "p.m."}); format.setDateFormatSymbols(symbols); Date date = format.parse(text); System.out.println(date); } }
String timeStampStrPlusYear = timestampStr + " " + year; SimpleDateFormat hackFormatter = new SimpleDateFormat(recentDateFormat.toPattern() + " yyyy", recentDateFormat.getDateFormatSymbols()); hackFormatter.setLenient(false); hackFormatter.setTimeZone(recentDateFormat.getTimeZone());
/** * {@inheritDoc} * * @deprecated as it is not considered to be thread safe. */ @Deprecated @Override public DateFormatSymbols getDateFormatSymbols() { return super.getDateFormatSymbols(); }
/** * @return returns an array of 12 strings representing the short * month names used by this parse. */ public String[] getShortMonths() { return defaultDateFormat.getDateFormatSymbols().getShortMonths(); }
/** * @return returns an array of 12 strings representing the short * month names used by this parse. */ public String[] getShortMonths() { return defaultDateFormat.getDateFormatSymbols().getShortMonths(); }
/** * Gets the date/time formatting data. * @return a copy of the date-time formatting data associated * with this date-time formatter. * @stable ICU 2.0 */ public DateFormatSymbols getDateFormatSymbols() { return new DateFormatSymbols(((java.text.SimpleDateFormat)dateFormat).getDateFormatSymbols()); }
/** * @return returns an array of 12 strings representing the short * month names used by this parse. */ public String[] getShortMonths() { return defaultDateFormat.getDateFormatSymbols().getShortMonths(); }
/** * @return returns an array of 12 strings representing the short * month names used by this parse. */ public String[] getShortMonths() { return defaultDateFormat.getDateFormatSymbols().getShortMonths(); }
public static String formatMonth(int month, Locale locale, boolean longFormat) { SimpleDateFormat sdf = new SimpleDateFormat("", getSafeLocale(locale)); if (longFormat) return sdf.getDateFormatSymbols().getMonths()[month]; else return sdf.getDateFormatSymbols().getShortMonths()[month]; }
/** * @return returns an array of 12 strings representing the short * month names used by this parse. */ public String[] getShortMonths() { return defaultDateFormat.getDateFormatSymbols().getShortMonths(); }
public static String formatMonth(Date d, Locale locale, boolean longFormat) { SimpleDateFormat sdf = new SimpleDateFormat("", getSafeLocale(locale)); Calendar c = Calendar.getInstance(getSafeLocale(locale)); c.setTime(d); int month = c.get(Calendar.MONTH); if (longFormat) return sdf.getDateFormatSymbols().getMonths()[month]; else return sdf.getDateFormatSymbols().getShortMonths()[month]; }
SimpleDateFormat sdf = new SimpleDateFormat("'z dnia' dd MMMM yyyy 'r.'"); DateFormatSymbols dfs = sdf.getDateFormatSymbols(); dfs.setMonths( new String[] { "stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia" }); sdf.setDateFormatSymbols(dfs); System.out.println( sdf.format(new GregorianCalendar(2012, Calendar.DECEMBER, 28).getTime()));
public static String formatDayOfWeek(Date d, Locale locale, boolean longFormat) { SimpleDateFormat sdf = new SimpleDateFormat("", getSafeLocale(locale)); Calendar c = Calendar.getInstance(getSafeLocale(locale)); c.setTime(d); int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); if (longFormat) return sdf.getDateFormatSymbols().getWeekdays()[dayOfWeek]; else return sdf.getDateFormatSymbols().getShortWeekdays()[dayOfWeek]; }
SimpleDateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.GERMAN); DateFormatSymbols dfs = df.getDateFormatSymbols(); String[] swd = {"", "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"}; dfs.setShortWeekdays(swd); df.setDateFormatSymbols(dfs);
public DateFormatSymbols getDateFormatSymbols() { Capturer.capture(Instrumenter.CAPTURE_ID_JAVA_TEXT_SIMPLEDATEFORMAT, this, "getDateFormatSymbols", "()Ljava/text/DateFormatSymbols;", new Object[] {}); DateFormatSymbols ret = super.getDateFormatSymbols(); Capturer.enable(Instrumenter.CAPTURE_ID_JAVA_TEXT_SIMPLEDATEFORMAT, this, ret); return ret; }
private void encodeDaysOfWeek(ResponseWriter writer, Locale locale) throws IOException { writer.startElement("tr", this); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm", locale); DateFormatSymbols dfs = sdf.getDateFormatSymbols(); encodeDayOfWeek(writer, (dfs.getWeekdays())[Calendar.MONDAY]); encodeDayOfWeek(writer, (dfs.getWeekdays())[Calendar.TUESDAY]); encodeDayOfWeek(writer, (dfs.getWeekdays())[Calendar.WEDNESDAY]); encodeDayOfWeek(writer, (dfs.getWeekdays())[Calendar.THURSDAY]); encodeDayOfWeek(writer, (dfs.getWeekdays())[Calendar.FRIDAY]); encodeDayOfWeek(writer, (dfs.getWeekdays())[Calendar.SATURDAY]); writer.endElement("tr"); }