I have an assignment that converts dates from one calendar system to another.
The documentation for GregorianCalendar seems to suggest that you can use dates with BCE years, but I have no idea how. If I simply make the year negative, i.e.
GregorianCalendar cal = new GregorianCalendar(-20, 1, 2, 3, 0, 0);
System.out.println(cal.getTime.toString());
It prints out 'Sun Feb 02 03:00:00 GMT-05:00 21', which is clearly not correct.
util. GregorianCalendar. setTimeZone() method is an in-built method in Java which modifies the current time zone to a new time zone according to the parameter passed. Parameters: The method takes one parameter tz of TimeZone object which specifies the new time zone value.
The days of the year in the Gregorian calendar are divided into 7-day weeks, and the weeks are numbered 1 to 52 or 53. The international standard is to start the week on Monday. However, several countries, including the US and Canada, count Sunday as the first day of the week.
YYYY/MM/DD - Sortable style Gregorian date format.
You need to set the ERA to BC (BC is a static field on GregorianCalendar).
The standard (Gregorian) calendar has 2 eras, BC and AD.
http://java.sun.com/j2se/1.4.2/docs/api/java/util/GregorianCalendar.html
e.g.
calendar.set(Calendar.ERA, GregorianCalendar.BC);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With