Looking further down, the documentation you linked has the same repeated snippet, only this time with a more detailed explanation, and it says:
Month, Formatted as two digits with Leading zeros as necessary, i.e. 01 - 13, Where "01" is the first Month of the year and ("13" is a special value required to support lunar calendars).
In free translation:
Month, formatted with two digits with zero preceding when needed. Ex: 01 to 13, where "01" is the first month of the year and ("13" is a special value required to support lunar calendars).
The name of the month in English is UNDECIMBER :
Value of the MONTH field indicating the Thirteenth Month of the year. Although Gregoriancalendar does not use this value, lunar calendars do.
In free translation:
Value of the MONTH field indicating the thirteenth month of the year. Although Gregoriancalendar does not use this value, lunar calendars use.
(In), fortunately, there is no standard Java class that supports the lunar calendar, but it is possible to find implementations made by lunatics like this one: hoveychen/lunar_calendar @ Github
When trying to use month 13 on a Gregorian calendar object, we get the first month of the following year. Example:
import java.util.Calendar;
public class Lunatico {
public static void main(String[] args) {
Calendar c1 = Calendar.getInstance();
c1.set(2015, Calendar.DECEMBER, 20); //data: 20/12/2015
Calendar c2 = Calendar.getInstance();
c2.set(2015, Calendar.UNDECIMBER, 20); //data: 20/13/2015
System.out.println(String.format("Dia normal: %1$te/%1$tm/%1$tY", c1));
System.out.println(String.format("Dia (quase) lunático: %1$te/%1$tm/%1$tY", c2));
System.out.println(String.format("\nMês: %1$tB", c2)); //escrevendo por extenso
}
}
Upshot:
Normal day: 20/12/2015
Lunatic day (almost) 20/01/2016
Month: January
Notice that inside the String.format()
I used the m
, as the documentation explains.
It is used in HR systems so that they can pay the 13th salary of their employees :)
– Math
@Math I don’t doubt it should be some gambiarra! Let’s see if anyone knows :D
– carlosrafaelgn
See this link too, I was curious about this lunatic thing Calendar of 13 moons
– abfurlan