java.text.SimpleDateFormat#getDateFormatSymbols ( )源码实例Demo

下面列出了java.text.SimpleDateFormat#getDateFormatSymbols ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: j2objc   文件: SimpleDateFormatTest.java
public void test_setDateFormatSymbolsLjava_text_DateFormatSymbols() {
    // Test for method void
    // java.text.SimpleDateFormat.setDateFormatSymbols(java.text.DateFormatSymbols)
    SimpleDateFormat f1 = new SimpleDateFormat("a");
    DateFormatSymbols symbols = new DateFormatSymbols();
    symbols.setAmPmStrings(new String[] { "morning", "night" });
    f1.setDateFormatSymbols(symbols);
    DateFormatSymbols newSym = f1.getDateFormatSymbols();
    assertTrue("Set incorrectly", newSym.equals(symbols));
    assertTrue("Not a clone", f1.getDateFormatSymbols() != symbols);
    String result = f1.format(new GregorianCalendar(1999, Calendar.JUNE, 12, 3, 0).getTime());
    assertEquals("Incorrect symbols used", "morning", result);
    symbols.setEras(new String[] { "before", "after" });
    assertTrue("Identical symbols", !f1.getDateFormatSymbols().equals(symbols));

    try {
        f1.setDateFormatSymbols(null);
        fail();
    } catch (NullPointerException expected) {
    }
}
 
源代码2 项目: fenixedu-academic   文件: UIFenixCalendar.java
private void encodeMonthRow(ResponseWriter writer, Calendar date, Locale locale) throws IOException {
    // writer.startElement("tr", this);
    // writer.startElement("td", this);
    writer.startElement("caption", this);
    writer.writeAttribute("style", "font-weight: 600; background: #bbb", null);
    writer.writeAttribute("class", "text-center", null);
    // writer.writeAttribute("colspan", 6, null);

    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm", locale);
    DateFormatSymbols dfs = sdf.getDateFormatSymbols();
    writer.write((dfs.getMonths())[date.get(Calendar.MONTH)]);

    writer.endElement("caption");
    // writer.endElement("td");
    // writer.endElement("tr");
}
 
源代码3 项目: mpxj   文件: MPXJBaseFormat.java
/**
 * Allows the AM/PM text to be set.
 *
 * @param am AM text
 * @param pm PM text
 */
public void setAmPmText(String am, String pm)
{
   for (SimpleDateFormat format : m_formats)
   {
      DateFormatSymbols symbols = format.getDateFormatSymbols();
      symbols.setAmPmStrings(new String[]
      {
         am,
         pm
      });
      format.setDateFormatSymbols(symbols);
   }
}
 
源代码4 项目: j2objc   文件: SimpleDateFormatTest.java
public void test_getDateFormatSymbols() {
    // Test for method java.text.DateFormatSymbols
    // java.text.SimpleDateFormat.getDateFormatSymbols()
    SimpleDateFormat df = (SimpleDateFormat) DateFormat.getInstance();
    DateFormatSymbols dfs = df.getDateFormatSymbols();
    assertTrue("Symbols identical", dfs != df.getDateFormatSymbols());
}
 
源代码5 项目: fenixedu-academic   文件: UIFenixCalendar.java
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");
}
 
源代码6 项目: nebula   文件: DateChooser.java
/**
 * Sets a new locale to use for calendar. Locale will define the names of
 * months and days, and the first day of week.
 *
 * @param locale new locale (must not be null)
 */
public void setLocale(Locale locale) {
	checkWidget();
	if (locale == null) {
		SWT.error(SWT.ERROR_NULL_ARGUMENT);
	}

	this.locale = locale;

	// Loads the resources
	resources = ResourceBundle.getBundle(BUNDLE_NAME, locale);
	prevMonth.setToolTipText(resources.getString("DateChooser.previousButton")); //$NON-NLS-1$
	nextMonth.setToolTipText(resources.getString("DateChooser.nextButton")); //$NON-NLS-1$

	// Defines formats
	df1 = new SimpleDateFormat("MMMM yyyy", locale); //$NON-NLS-1$
	df2 = DateFormat.getDateInstance(DateFormat.SHORT, locale);
	final Calendar c = Calendar.getInstance(TimeZone.getDefault(), locale);
	firstDayOfWeek = c.getFirstDayOfWeek();
	minimalDaysInFirstWeek = Integer.parseInt(resources.getString("minimalDaysInFirstWeek"));
	if (currentMonthCal != null) {
		currentMonthCal.setFirstDayOfWeek(firstDayOfWeek);
		currentMonthCal.setMinimalDaysInFirstWeek(minimalDaysInFirstWeek);
	}
	if (todayCal != null) {
		todayCal.setFirstDayOfWeek(firstDayOfWeek);
		todayCal.setMinimalDaysInFirstWeek(minimalDaysInFirstWeek);
	}

	// Sets the header menu items
	final String[] months = df1.getDateFormatSymbols().getMonths();
	final MenuItem[] items = monthsMenu.getItems();
	for (int i = 0; i < 12; i++) {
		items[i].setText(months[i]);
	}

	// Sets the grid header initials
	redrawInc();
	final DateFormatSymbols symboles = df1.getDateFormatSymbols();
	final String[] sn = symboles.getShortWeekdays();
	final String[] ln = symboles.getWeekdays();
	int f = firstDayOfWeek;
	for (int i = 1; i < headers.length; i++) {
		headers[i].setText(sn[f].substring(0, 1).toUpperCase());
		headers[i].setToolTipText(ln[f]);
		f = f % 7 + 1;
	}

	// Updates the footer
	updateTodayLabel();

	refreshDisplay();
	redrawDec();
}
 
源代码7 项目: dhis2-core   文件: I18nFormat.java
public void init()
{
    String[] months = { "month.january", "month.february", "month.march", "month.april", "month.may", "month.june",
        "month.july", "month.august", "month.september", "month.october", "month.november", "month.december" };
    String[] shortMonths = { "month.short.january", "month.short.february", "month.short.march",
        "month.short.april", "month.short.may", "month.short.june", "month.short.july", "month.short.august",
        "month.short.september", "month.short.october", "month.short.november", "month.short.december" };
    String[] weekdays = { "weekday.sunday", "weekday.monday", "weekday.tuesday", "weekday.wednesday",
        "weekday.thursday", "weekday.friday", "weekday.saturday" };
    String[] shortWeekdays = { "weekday.short.sunday", "weekday.short.monday", "weekday.short.tuesday",
        "weekday.short.wednesday", "weekday.short.thursday", "weekday.short.friday", "weekday.short.saturday" };

    String calendarName = PeriodType.getCalendar().name() + ".";

    for ( int i = 0; i < 12; ++i )
    {
        if ( resourceBundle.containsKey( calendarName + months[i] ) )
        {
            months[i] = resourceBundle.getString( calendarName + months[i] );
        }
        else
        {
            months[i] = resourceBundle.getString( months[i] );
        }

        if ( resourceBundle.containsKey( calendarName + shortMonths[i] ) )
        {
            shortMonths[i] = resourceBundle.getString( calendarName + shortMonths[i] );
        }
        else
        {
            shortMonths[i] = resourceBundle.getString( shortMonths[i] );
        }
    }

    for ( int i = 0; i < 7; ++i )
    {
        if ( resourceBundle.containsKey( calendarName + weekdays[i] ) )
        {
            weekdays[i] = resourceBundle.getString( calendarName + weekdays[i] );
        }
        else
        {
            weekdays[i] = resourceBundle.getString( weekdays[i] );
        }

        if ( resourceBundle.containsKey( calendarName + shortWeekdays[i] ) )
        {
            shortWeekdays[i] = resourceBundle.getString( calendarName + shortWeekdays[i] );
        }
        else
        {
            shortWeekdays[i] = resourceBundle.getString( shortWeekdays[i] );
        }
    }

    SimpleDateFormat dateFormat = new SimpleDateFormat();
    dateFormatSymbols = dateFormat.getDateFormatSymbols();

    dateFormatSymbols.setMonths( months );
    dateFormatSymbols.setShortMonths( shortMonths );
    dateFormatSymbols.setWeekdays( weekdays );
    dateFormatSymbols.setShortWeekdays( shortWeekdays );
}