Java 8 DateFormatSymbols - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DateFormatSymbols class.

This code example shows how to use the following methods:equals, setAmPmStrings, setEras
 
    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("NullPointerException was not thrown.");
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAmPmStrings, getEras, getMonths, getShortMonths, getShortWeekdays
	protected final String[] shortWeekdays;
	protected final String[] eras;
	protected final String[] ampms;
 
	public DateFormatSymbolsEx(Locale locale) {
		DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(locale);
 
		months = dateFormatSymbols.getMonths();
		shortMonths = dateFormatSymbols.getShortMonths();
		weekdays = dateFormatSymbols.getWeekdays();
		shortWeekdays = dateFormatSymbols.getShortWeekdays();
		eras = dateFormatSymbols.getEras();
		ampms = dateFormatSymbols.getAmPmStrings();
	} 
 
	// ---------------------------------------------------------------- getters 
 
	/** 
	 * Returns month string. 
	 */ 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
public class AjaxDatePickerExample extends WOComponent { 
	 
	public NSTimestamp someValue = new NSTimestamp(); 
	public Format formatter = new NSTimestampFormatter("%m/%d/%Y"); 
 
	public Format frenchFormatter = new NSTimestampFormatter("%e %b %Y", new DateFormatSymbols(Locale.FRENCH));	 
	public NSArray<String> frenchMonths = new NSArray<String>(new String[]{ 
			"janvier", "février", "mars", "avril", "mai", "juin", 
			"juillet", "août", "septembre", "octobre", "novembre", "décembre"}); 
 
	public NSArray<String> frenchDays = new NSArray<String>(new String[]{ 
			"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}); 
 
	public String customFormat = "dd MMM yyyy"; 
	public NSTimestamp customValue = new NSTimestamp(); 
	 
    public AjaxDatePickerExample(WOContext context) { 
        super(context); 
    } 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getMonths, getWeekdays
public class Dates 
{ 
 public static void main(final String[] args)
 { 
  Calendar now = new GregorianCalendar(); //months are 0 indexed, dates are 1 indexed
  DateFormatSymbols symbols = new DateFormatSymbols(); //names for our months and weekdays
 
  //plain numbers way 
  System.out.println(now.get(Calendar.YEAR)  + "-" + (now.get(Calendar.MONTH) + 1) + "-" + now.get(Calendar.DATE));
 
  //words way 
  System.out.print(symbols.getWeekdays()[now.get(Calendar.DAY_OF_WEEK)] + ", ");
  System.out.print(symbols.getMonths()[now.get(Calendar.MONTH)] + " ");
  System.out.println(now.get(Calendar.DATE) + ", " + now.get(Calendar.YEAR));
 
  //using DateFormat 
  Date date = new Date();
  DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
  System.out.println(format1.format(date));
  DateFormat format2 = new SimpleDateFormat("EEEE, MMMM dd, yyyy");
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getMonths, getShortMonths, getWeekdays
		Locale locale1 = LocaleUtil.getLocale("fr", "FR");
		Locale locale2 = LocaleUtil.getLocale("fr_FR");
		assertSame(locale1, locale2);
 
		DateFormatSymbolsEx dfs = LocaleUtil.getDateFormatSymbols(locale2);
		DateFormatSymbols dfsJava = new DateFormatSymbols(locale2);
		assertEquals(dfs.getMonth(0), dfsJava.getMonths()[0]);
		assertEquals(dfs.getWeekday(1), dfsJava.getWeekdays()[1]);
		assertEquals(dfs.getShortMonth(2), dfsJava.getShortMonths()[2]);
 
		locale1 = LocaleUtil.getLocale("en");
		locale2 = LocaleUtil.getLocale("en_EN");
		assertNotSame(locale1, locale2);
 
		dfs = LocaleUtil.getDateFormatSymbols(locale2);
		dfsJava = new DateFormatSymbols(locale2);
		assertEquals(dfs.getMonth(0), dfsJava.getMonths()[0]);
		assertEquals(dfs.getWeekday(1), dfsJava.getWeekdays()[1]);
		assertEquals(dfs.getShortMonth(2), dfsJava.getShortMonths()[2]);
	} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:equals, setAmPmStrings, setEras
 
    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("NullPointerException was not thrown.");
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getMonths, getWeekdays, getZoneStrings
        assertEquals("en_US_POSIX", locale.toString());
    } 
 
    public void testResourceBundles() throws Exception {
        Locale eng = new Locale("en", "US");
        DateFormatSymbols engSymbols = new DateFormatSymbols(eng);
 
        Locale deu = new Locale("de", "DE");
        DateFormatSymbols deuSymbols = new DateFormatSymbols(deu);
 
        TimeZone berlin = TimeZone.getTimeZone("Europe/Berlin");
 
        assertEquals("January", engSymbols.getMonths()[0]);
        assertEquals("Januar", deuSymbols.getMonths()[0]);
 
        assertEquals("Sunday", engSymbols.getWeekdays()[Calendar.SUNDAY]);
        assertEquals("Sonntag", deuSymbols.getWeekdays()[Calendar.SUNDAY]);
 
        assertEquals("Central European Standard Time",
                berlin.getDisplayName(false, TimeZone.LONG, eng));

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getMonths, getWeekdays
 
    /** 
     * Creates a new utility class for the default locale. 
     */ 
    public SerialDateUtilities() { 
        this.dateFormatSymbols = new DateFormatSymbols();
        this.weekdays = this.dateFormatSymbols.getWeekdays();
        this.months = this.dateFormatSymbols.getMonths();
    } 
 
    /** 
     * Returns an array of strings representing the days-of-the-week. 
     * 
     * @return an array of strings representing the days-of-the-week. 
     */ 
    public String[] getWeekdays() {
        return this.weekdays;
    } 
 
    /** 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getMonths, getShortMonths, getShortWeekdays, getWeekdays
     * Creates a DateString insatnce, configured for the specified language. 
     * The name of the language  has to be an ISO 639 code. 
     */ 
    public DateStrings(String language) {
        Locale aLocale = new Locale(language);
        DateFormatSymbols symbols = new DateFormatSymbols(aLocale);
         
        day = symbols.getShortWeekdays();
        longday = symbols.getWeekdays();
        month = symbols.getShortMonths();
        longmonth = symbols.getMonths();
         
        if (language.equals("nl")) {
            day=Dutch_days;
        } 
    } 
 
    public String getMonth(int monthInt) {
        return longmonth[monthInt];
    } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getMonths, getShortMonths, getShortWeekdays, getWeekdays
    getButtonText().setWeek(getString("calendar.week")); 
    getButtonText().setMonth(getString("calendar.month")); 
    getButtonText().setDay(getString("calendar.day")); 
    setAllDayText(getString("calendar.allday")); 
    I18nCore.setFullCalendarDateFormats(PFUserContext.getUser(), this);
    final DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(parent.getLocale());
    setDayNames(convert(dateFormatSymbols.getWeekdays()));
    setDayNamesShort(convert(dateFormatSymbols.getShortWeekdays()));
    setMonthNames(dateFormatSymbols.getMonths());
    setMonthNamesShort(dateFormatSymbols.getShortMonths());
    setWeekMode("variable"); 
    setEnableContextMenu(true); 
    setEventRenderModel(Model.of("function(event, element) {" + 
                "if (event.tooltipTitle) {" + 
                    "element.popover({" + 
                        "container: document.body, " + 
                        "title: event.tooltipTitle, " + 
                        "content: event.tooltipContent, " + 
                        "html: true, " + 
                        "placement: 'mouse'," + 
6
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Java 8 DateFormatSymbols Questions & Answers:

See Code Examples for Java 8 DateFormatSymbols Methods: