Month name in genitive (Polish locale) with Joda-Time DateTimeFormatter

后端 未结 2 1449
情书的邮戳
情书的邮戳 2020-12-15 05:18

I have LocalDate which contains date 2012-12-28 and I want to print it with localized month name (i.e. December in Polish) in genitive which in

2条回答
  •  抹茶落季
    2020-12-15 05:35

    Do you really need to use Joda? Replacing the month names is trivial using the date formatters in the standard Java API:

    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()));
    

提交回复
热议问题