File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes more Calendar stuff Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "more Calendar stuff" Watch "more Calendar stuff" New topic

more Calendar stuff

andrew mcmillan

Joined: Jun 06, 2001
Posts: 14
when outputting a date string from a Calendar in SHORT format i get the string '25.10.01'. but if i read this string back in to set the calendar date it assumes the year to be 0001 and not 2001.
how do i get the Calendar or DateForat class to assume that if year 01 is found assume its 2001 not 0001.
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Andrew,
Whenever you use DateFormat you must use it on both ends. What does that mean? Well you have used it to output your string into SHORT form, so you must also use it when you read in back in from SHORT form. The following example shows what I am talking about.

Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
You can also use a SimpleDateFormat, which allows you to specify how two-digit years are interpreted using the method set2DigitYearStart().

"I'm not back." - Bill Harding, Twister
Don't get me started about those stupid light bulbs.
subject: more Calendar stuff
It's not a secret anymore!