Java says the year 0 is a leap year but year 0 never existed
Clash Royale CLAN TAG#URR8PPP
up vote
6
down vote
favorite
I was writing some test cases for some convenience methods that I am updating and decided to see what would happen if I used LocalDate's isLeapYear() method on the year 0. As I understand it, year 0 never actually existed: the year before 1 AD was 1 BC. (This is based on an article I read many years ago whose source I have long forgotten.) Much to my surprise, my test indicated that the year 0 wa a leap year!
I realize that the java.time.LocalDate class implements ISO-8601 but does ISO-8601 really indicate that the year 0 existed? I'm reluctant to believe that the people who tested LocalDate would have missed this as a test case but I'm also reluctant to believe that an international standard like ISO-8601 would make such an obvious mistake.
The other possibility is that the article I read was just flat-out wrong. (Or it was correct then but was rethought later.)
This is not hugely important but I am curious to know where the mistake is: ISO-8601, Java's LocalDate class, or my understanding of how time is reckoned.
java time
add a comment |Â
up vote
6
down vote
favorite
I was writing some test cases for some convenience methods that I am updating and decided to see what would happen if I used LocalDate's isLeapYear() method on the year 0. As I understand it, year 0 never actually existed: the year before 1 AD was 1 BC. (This is based on an article I read many years ago whose source I have long forgotten.) Much to my surprise, my test indicated that the year 0 wa a leap year!
I realize that the java.time.LocalDate class implements ISO-8601 but does ISO-8601 really indicate that the year 0 existed? I'm reluctant to believe that the people who tested LocalDate would have missed this as a test case but I'm also reluctant to believe that an international standard like ISO-8601 would make such an obvious mistake.
The other possibility is that the article I read was just flat-out wrong. (Or it was correct then but was rethought later.)
This is not hugely important but I am curious to know where the mistake is: ISO-8601, Java's LocalDate class, or my understanding of how time is reckoned.
java time
This would be a great Jon Skeet question.
â Ryan The Leach
5 hours ago
Thanks, everyone! I'm glad to see that LocalDate doesn't have an obvious error in it. I'm going to have to get used to thinking of a timeline like a thermometer with negative, zero and positive values again....
â Henry
3 hours ago
add a comment |Â
up vote
6
down vote
favorite
up vote
6
down vote
favorite
I was writing some test cases for some convenience methods that I am updating and decided to see what would happen if I used LocalDate's isLeapYear() method on the year 0. As I understand it, year 0 never actually existed: the year before 1 AD was 1 BC. (This is based on an article I read many years ago whose source I have long forgotten.) Much to my surprise, my test indicated that the year 0 wa a leap year!
I realize that the java.time.LocalDate class implements ISO-8601 but does ISO-8601 really indicate that the year 0 existed? I'm reluctant to believe that the people who tested LocalDate would have missed this as a test case but I'm also reluctant to believe that an international standard like ISO-8601 would make such an obvious mistake.
The other possibility is that the article I read was just flat-out wrong. (Or it was correct then but was rethought later.)
This is not hugely important but I am curious to know where the mistake is: ISO-8601, Java's LocalDate class, or my understanding of how time is reckoned.
java time
I was writing some test cases for some convenience methods that I am updating and decided to see what would happen if I used LocalDate's isLeapYear() method on the year 0. As I understand it, year 0 never actually existed: the year before 1 AD was 1 BC. (This is based on an article I read many years ago whose source I have long forgotten.) Much to my surprise, my test indicated that the year 0 wa a leap year!
I realize that the java.time.LocalDate class implements ISO-8601 but does ISO-8601 really indicate that the year 0 existed? I'm reluctant to believe that the people who tested LocalDate would have missed this as a test case but I'm also reluctant to believe that an international standard like ISO-8601 would make such an obvious mistake.
The other possibility is that the article I read was just flat-out wrong. (Or it was correct then but was rethought later.)
This is not hugely important but I am curious to know where the mistake is: ISO-8601, Java's LocalDate class, or my understanding of how time is reckoned.
java time
java time
asked 5 hours ago
Henry
23219
23219
This would be a great Jon Skeet question.
â Ryan The Leach
5 hours ago
Thanks, everyone! I'm glad to see that LocalDate doesn't have an obvious error in it. I'm going to have to get used to thinking of a timeline like a thermometer with negative, zero and positive values again....
â Henry
3 hours ago
add a comment |Â
This would be a great Jon Skeet question.
â Ryan The Leach
5 hours ago
Thanks, everyone! I'm glad to see that LocalDate doesn't have an obvious error in it. I'm going to have to get used to thinking of a timeline like a thermometer with negative, zero and positive values again....
â Henry
3 hours ago
This would be a great Jon Skeet question.
â Ryan The Leach
5 hours ago
This would be a great Jon Skeet question.
â Ryan The Leach
5 hours ago
Thanks, everyone! I'm glad to see that LocalDate doesn't have an obvious error in it. I'm going to have to get used to thinking of a timeline like a thermometer with negative, zero and positive values again....
â Henry
3 hours ago
Thanks, everyone! I'm glad to see that LocalDate doesn't have an obvious error in it. I'm going to have to get used to thinking of a timeline like a thermometer with negative, zero and positive values again....
â Henry
3 hours ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
6
down vote
accepted
From the LocalDate
Javadoc:
It is equivalent to the proleptic Gregorian calendar system, in which today's rules for leap years are applied for all time. For most applications written today, the ISO-8601 rules are entirely suitable. However, any application that makes use of historical dates, and requires them to be accurate will find the ISO-8601 approach unsuitable.
Wikipedia has more information on the proleptic Gregorian calendar. Among other things, it says:
Mathematically, it is more convenient to include a year 0 and represent earlier years as negative, for the specific purpose of facilitating the calculation of the number of years between a negative (BC) year and a positive (AD) year. This is the convention used in astronomical year numbering and in the international standard date system, ISO 8601. In these systems, the year 0 is a leap year.
Note that this has nothing to do with the AD/BC versus CE/BCE terminology: those names are only used for referring to which era of years is being used, not the calendar in use.
1
Good to know they know about their limitations. Nice find.
â Alain Cruz
4 hours ago
add a comment |Â
up vote
4
down vote
From Wikipedia:
...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)
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
accepted
From the LocalDate
Javadoc:
It is equivalent to the proleptic Gregorian calendar system, in which today's rules for leap years are applied for all time. For most applications written today, the ISO-8601 rules are entirely suitable. However, any application that makes use of historical dates, and requires them to be accurate will find the ISO-8601 approach unsuitable.
Wikipedia has more information on the proleptic Gregorian calendar. Among other things, it says:
Mathematically, it is more convenient to include a year 0 and represent earlier years as negative, for the specific purpose of facilitating the calculation of the number of years between a negative (BC) year and a positive (AD) year. This is the convention used in astronomical year numbering and in the international standard date system, ISO 8601. In these systems, the year 0 is a leap year.
Note that this has nothing to do with the AD/BC versus CE/BCE terminology: those names are only used for referring to which era of years is being used, not the calendar in use.
1
Good to know they know about their limitations. Nice find.
â Alain Cruz
4 hours ago
add a comment |Â
up vote
6
down vote
accepted
From the LocalDate
Javadoc:
It is equivalent to the proleptic Gregorian calendar system, in which today's rules for leap years are applied for all time. For most applications written today, the ISO-8601 rules are entirely suitable. However, any application that makes use of historical dates, and requires them to be accurate will find the ISO-8601 approach unsuitable.
Wikipedia has more information on the proleptic Gregorian calendar. Among other things, it says:
Mathematically, it is more convenient to include a year 0 and represent earlier years as negative, for the specific purpose of facilitating the calculation of the number of years between a negative (BC) year and a positive (AD) year. This is the convention used in astronomical year numbering and in the international standard date system, ISO 8601. In these systems, the year 0 is a leap year.
Note that this has nothing to do with the AD/BC versus CE/BCE terminology: those names are only used for referring to which era of years is being used, not the calendar in use.
1
Good to know they know about their limitations. Nice find.
â Alain Cruz
4 hours ago
add a comment |Â
up vote
6
down vote
accepted
up vote
6
down vote
accepted
From the LocalDate
Javadoc:
It is equivalent to the proleptic Gregorian calendar system, in which today's rules for leap years are applied for all time. For most applications written today, the ISO-8601 rules are entirely suitable. However, any application that makes use of historical dates, and requires them to be accurate will find the ISO-8601 approach unsuitable.
Wikipedia has more information on the proleptic Gregorian calendar. Among other things, it says:
Mathematically, it is more convenient to include a year 0 and represent earlier years as negative, for the specific purpose of facilitating the calculation of the number of years between a negative (BC) year and a positive (AD) year. This is the convention used in astronomical year numbering and in the international standard date system, ISO 8601. In these systems, the year 0 is a leap year.
Note that this has nothing to do with the AD/BC versus CE/BCE terminology: those names are only used for referring to which era of years is being used, not the calendar in use.
From the LocalDate
Javadoc:
It is equivalent to the proleptic Gregorian calendar system, in which today's rules for leap years are applied for all time. For most applications written today, the ISO-8601 rules are entirely suitable. However, any application that makes use of historical dates, and requires them to be accurate will find the ISO-8601 approach unsuitable.
Wikipedia has more information on the proleptic Gregorian calendar. Among other things, it says:
Mathematically, it is more convenient to include a year 0 and represent earlier years as negative, for the specific purpose of facilitating the calculation of the number of years between a negative (BC) year and a positive (AD) year. This is the convention used in astronomical year numbering and in the international standard date system, ISO 8601. In these systems, the year 0 is a leap year.
Note that this has nothing to do with the AD/BC versus CE/BCE terminology: those names are only used for referring to which era of years is being used, not the calendar in use.
edited 4 hours ago
answered 4 hours ago
Daniel Pryden
43.4k769115
43.4k769115
1
Good to know they know about their limitations. Nice find.
â Alain Cruz
4 hours ago
add a comment |Â
1
Good to know they know about their limitations. Nice find.
â Alain Cruz
4 hours ago
1
1
Good to know they know about their limitations. Nice find.
â Alain Cruz
4 hours ago
Good to know they know about their limitations. Nice find.
â Alain Cruz
4 hours ago
add a comment |Â
up vote
4
down vote
From Wikipedia:
...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)
add a comment |Â
up vote
4
down vote
From Wikipedia:
...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)
add a comment |Â
up vote
4
down vote
up vote
4
down vote
From Wikipedia:
...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)
From Wikipedia:
...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)
edited 4 hours ago
answered 5 hours ago
Alex Taylor
5,14621532
5,14621532
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52921032%2fjava-says-the-year-0-is-a-leap-year-but-year-0-never-existed%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
This would be a great Jon Skeet question.
â Ryan The Leach
5 hours ago
Thanks, everyone! I'm glad to see that LocalDate doesn't have an obvious error in it. I'm going to have to get used to thinking of a timeline like a thermometer with negative, zero and positive values again....
â Henry
3 hours ago