Calendar.UNDECIMBER做什么? [英] What does Calendar.UNDECIMBER do?

查看:327
本文介绍了Calendar.UNDECIMBER做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Calendar 类中有一个常量,名为: UNDECIMBER 。它描述了第13个月。

There is a constant in the Calendar class called: UNDECIMBER. It describes the 13th month.

此常量是否有用?在维基百科中,它写的是农历。但是这个日历没有实现。

Is there a useful purpose for this constant? In Wikipedia it is written that it is for the lunar calendar. But there is no implementation for such calendar.

第14个月是否存在任何解决方案(Duodecimber)?

And does there exist any solutions for the 14th month (Duodecimber)?

我在网上找不到这么多,我想更多地了解这个话题。

I didn't found so much in the web, and I would like to find out more about this topic.

推荐答案

正如已经说过的,一些月球(和其他古代)日历有13个月。一个例子是科普特日历

As already said, some lunar (and other ancient) calendars have 13 months. One example is the Coptic Calendar.

虽然没有13个月的日历实现扩展 java.util.Calendar ,但在Java 8的新API中有一些。随着新的java.time API 的推出,它也被创建了< a href =http://www.threeten.org/threeten-extra/ =nofollow noreferrer> ThreeTen Extra项目,其中包含一个实现

Although there are no implementations of calendars with 13 months that extends java.util.Calendar, in Java 8's new API there are some. With the introduction of the new java.time API, it was also created the ThreeTen Extra project, which contains an implementation for that.

该类是 org.threeten.extra.chrono.CopticChronology ,它扩展了本机 java.time.chrono.Chronology 。我刚刚制作了一个示例代码,用于在此日历中创建日期并循环显示其日期:

The class is org.threeten.extra.chrono.CopticChronology, which extends the native java.time.chrono.Chronology. I've just made a sample code to create a date in this calendar and loop through its months:

// Coptic calendar
CopticChronology cal = CopticChronology.INSTANCE;
// range for month of year (from 1 to 13)
System.out.println("month range: " + cal.range(ChronoField.MONTH_OF_YEAR)); // 1 - 13

// getting a date in Coptic calendar and loop through the months
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("dd/MM/yyyy");
// September 11th is equivalent to 01/01 in Coptic calendar
CopticDate d = cal.date(LocalDate.of(2017, 9, 11));
for (int i = 0; i < 14; i++) {
    System.out.println(fmt.format(d));
    d = d.plus(1, ChronoUnit.MONTHS);
}

输出为:

month range: 1 - 13
01/01/1734
01/02/1734
01/03/1734
01/04/1734
01/05/1734
01/06/1734
01/07/1734
01/08/1734
01/09/1734
01/10/1734
01/11/1734
01/12/1734
01/13/1734
01/01/1735

请注意,年度在13 th 月之后发生了变化。

Note that the year changed just after the 13th month.

ThreeTen Extra项目还有 埃塞俄比亚日历的实施 ,也有13个月。

The ThreeTen Extra project also has an implementation for the Ethiopian calendar, which has 13 months as well.

并且,作为14个月的日历示例,有一个 PaxChronology class ,它实现了 Pax日历:据我所知,拟议的改革日历系统,但目前尚未使用。

And, as an example of a calendar with 14 months, there's the PaxChronology class, which implements the Pax Calendar: a proposed reform calendar system, but not currently in use, as far as I know.

引用维基百科:


普通年份分为13个月,每个28天,其名称与公历中的相同,只有一个月叫做哥伦布十一月到十二月之间。每周,每月和每年的第一天是星期日。

The common year is divided into 13 months of 28 days each, whose names are the same as in the Gregorian calendar, except that a month called Columbus occurs between November and December. The first day of every week, month and year would be Sunday.

在闰年,将在哥伦布之后插入一个为期一周的称为Pax的月份。

In leap years, a one-week month called Pax would be inserted after Columbus.

根据 javadoc


闰年发生在每一年的最后两位数可以被6整除,是99,或者是00,年份不能被400整除。

Leap years occur in every year whose last two digits are divisible by 6, are 99, or are 00 and the year is not divisible by 400.

示例:

PaxChronology paxCal = PaxChronology.INSTANCE;
System.out.println("month range: " + paxCal.range(ChronoField.MONTH_OF_YEAR));

PaxDate pd = paxCal.date(1930, 1, 1);
for (int i = 0; i < 15; i++) {
    // fmt is the same DateTimeFormatter from previous example
    System.out.println(fmt.format(pd));
    // adjusting for first day of next month - using TemporalAdjuster because
    // adding 1 ChronoUnit.MONTHS throws an exception for 14th month (not sure why)
    pd = pd.plus(30, ChronoUnit.DAYS).with(TemporalAdjusters.firstDayOfMonth());
}

输出:

month range: 1 - 13/14
01/01/1930
01/02/1930
01/03/1930
01/04/1930
01/05/1930
01/06/1930
01/07/1930
01/08/1930
01/09/1930
01/10/1930
01/11/1930
01/12/1930
01/13/1930
01/14/1930
01/01/1931

您可以注意到年份在14 之后发生变化月。
范围 1 - 13/14 因为年份可能有13个月或14个月,具体取决于它是否为闰年。

You can notice that the year changes after the 14th month. The range is 1 - 13/14 because years can have 13 or 14 months, depending if it's a leap year or not.

这篇关于Calendar.UNDECIMBER做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆