相关疑难解决方法(0)

使用Joda-Time DateTimeFormatter的genitive(波兰语语言环境)中的月份名称

我有LocalDate包含日期2012-12-28,我希望与本地的月名称(即十二月波兰)打印出来的所有格这在波兰是主格不同(grudniagrudzień分别).因为我也想使用自定义格式,我创建了自己的DateTimeFormatter使用DateTimeFormatterBuilder(在Joda-Time中,AFAIK是正确的方式):

private static final DateTimeFormatter CUSTOM_DATE_FORMATTER
    = new DateTimeFormatterBuilder()
        .appendLiteral("z dnia ")
        .appendDayOfMonth(1)
        .appendLiteral(' ')
        .appendText(new MonthNameGenitive()) // <--
        .appendLiteral(' ')
        .appendYear(4, 4)
        .appendLiteral(" r.")
        .toFormatter()
        .withLocale(new Locale("pl", "PL")); // not used in this case apparently
Run Code Online (Sandbox Code Playgroud)

输出应为" z dnia 28 grudnia 2012 r. ".

我的问题是关于标有箭头的线:我应该如何实施MonthNameGenitive?目前它扩展DateTimeFieldType并且有很多代码:

final class MonthNameGenitive extends DateTimeFieldType {
  private static final long serialVersionUID = 1L;

  MonthNameGenitive() {
    super("monthNameGenitive");
  }

  @Override
  public …
Run Code Online (Sandbox Code Playgroud)

java jodatime

21
推荐指数
1
解决办法
4767
查看次数

标签 统计

java ×1

jodatime ×1