Re: Exception questions
On 26-03-2010 21:56, Arne Vajh??j wrote:
On 26-03-2010 21:39, Lew wrote:
Arne Vajh??j wrote:
Please read the text.
<quote>
"Year zero" does not exist in the widely used Gregorian calendar or in
its predecessor, the Julian calendar. Under those systems, the year 1
BC is followed by AD 1.
</quote>
We use GregorianCalender, so:
<quote>
However, there is a year zero in astronomical year numbering (where it
coincides with the Julian year 1 BC) and in ISO 8601:2004 (where it
coincides with the Gregorian year 1 BC) as well as in all Buddhist and
Hindu calendars.
</quote>
is of little relevance.
It's entirely relevant because the ISO 8601 version, the one that does
have a year 0, is the version implemented by java.util.Calendar.
?
java.util.Calendar.getInstance return a java.util.GregorianCalendar.
The Java Docs for java.util.GregorianCalendar explicit state:
<quote>
Value of the ERA field indicating the period before the common era
(before Christ), also known as BCE. The sequence of years at the
transition from BC to AD is ..., 2 BC, 1 BC, 1 AD, 2 AD,...
</quote>
Where did you see that it should have a year zero ?
I notice on the one hand you argue for projecting the system back to
prior to its invention, when you argue in favor of a year "one", but for
not projecting the system back when it justifies having a year "zero".
That is inconsistent.
It depends on which version of the Gregorian calendar you use. Since
this is a Java discussion, I'm using the one that Java uses.
Me to !
And a standard SUN Java 1.6 seems to follow docs:
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class TestCalendar {
private static DateFormat df = new SimpleDateFormat("MMMM d y G");
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
System.out.println(cal.getClass().getName());
cal.set(Calendar.YEAR, 1);
System.out.println(df.format(cal.getTime()));
System.out.println(cal.get(Calendar.YEAR));
cal.add(Calendar.YEAR, -1);
System.out.println(df.format(cal.getTime()));
System.out.println(cal.get(Calendar.YEAR));
}
}
java.util.GregorianCalendar
marts 26 01 AD
1
marts 26 01 BC
1
Arne