my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Difference between Year and Week year in SimpleDateFormat's pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Difference between Year and Week year in SimpleDateFormat Watch "Difference between Year and Week year in SimpleDateFormat New topic
Author

Difference between Year and Week year in SimpleDateFormat's pattern

Nick Widelec
Ranch Hand

Joined: Feb 28, 2013
Posts: 226

Directly from this API

"
y Year Year 1996; 96
Y Week year Year 2009; 09

"

I have tested those two keywords for creating patterns, and they produce the same result.
What do they mean by Week year in that context?




OCAJP 7, OCPJP 7
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18988
    
  40

Nick Widelec wrote:Directly from this API

"
y Year Year 1996; 96
Y Week year Year 2009; 09

"

I have tested those two keywords for creating patterns, and they produce the same result.
What do they mean by Week year in that context?


A week year is a year where all the weeks in the year are whole weeks. This is specified by some standard (which I don't remember at the moment). Basically, this guarantees that a program working on a week's data will not transition between years. Unfortunately, this also means that the beginning of the year may not start on the first of January. What year a particular day belongs in depends on these rules, and of course, there are days where the year and the week year are different.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
 
subject: Difference between Year and Week year in SimpleDateFormat's pattern