Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between year-of-era and week-based-year?

Java 8's DateTimeFormatter class has a method, ofPattern(String pattern), that lets you define a format from a string of A-z, a-z letters. The examples don't clarify the difference between y, year-of-era and Y, week-based-year. What is it?

Symbol  Meaning                     Presentation      Examples ------  -------                     ------------      -------  y       year-of-era                 year              2004; 04  Y       week-based-year             year              1996; 96 
like image 488
Brian Avatar asked Oct 17 '14 19:10

Brian


People also ask

What is week based year?

In a week-based-year, each week belongs to only a single year. Week 1 of a year is the first week that starts on the first day-of-week and has at least the minimum number of days. The first and last weeks of a year may contain days from the previous calendar year or next calendar year respectively.

What is the difference between year and week year?

“Week year” is intended to be used for week dates, e.g. “2015-W01-1”, but is often mistakenly used for calendar dates, e.g. 2014-12-29, in which case the year may be incorrect during the last week of the year. If you are formatting anything other than a week date, you should use the year specifier “yyyy” instead.

What is the first week of the year?

The extra week is sometimes referred to as a leap week, although ISO 8601 does not use this term. Weeks start with Monday and end on Sunday. Each week's year is the Gregorian year in which the Thursday falls. The first week of the year, hence, always contains 4 January.

How are week numbers calculated?

The week number is the count of weeks that have passed in the year up to the end of the current week. For example, if it's the second week of the year, the week number is 2. The week where Jan 1 falls counts as the first week for the following year.


1 Answers

That's year value for "year-week" style dates, as in 2006-W52. It may be off the year-of-era value by +1 or -1 if the week in question straddles year boundary.

See http://en.wikipedia.org/wiki/ISO_8601#Week_dates

like image 84
hslugs Avatar answered Sep 23 '22 05:09

hslugs