File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Need Help in understanding DateFormat.parse() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Need Help in understanding DateFormat.parse() " Watch "Need Help in understanding DateFormat.parse() " New topic
Author

Need Help in understanding DateFormat.parse()

Md. Minhajur Rahman
Ranch Hand

Joined: Apr 10, 2012
Posts: 33
The output of the following snippet is Wed Jan 13 00:00:00 BDT 2011. But why, please anyone help...
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18108
    
  39

Md. Minhajur Rahman wrote:The output of the following snippet is Wed Jan 13 00:00:00 BDT 2011. But why, please anyone help...



Well, that's hard to say, because you are using lenient mode -- and in that mode the class is allowed to do all sorts of things to avoid throwing an error. This is in addition to the processing of whether the year is two digits versus four digits, etc.

I can however, speculate. I think negative years are BC (before Christ) years. So the printout is actually for the year 2011 BC !! .... Now a little trivia. There is no such a thing as year zero. It goes from year 3 BC to year 2 BC to year 1 BC to year 1 AD to year 2 AD, etc. And since there is no such a thing as year zero, I am going to speculate that 0 maps to year 1 BC, -1 maps to year 2 BC, -2 maps to year 3 BC, etc.

Henry



Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Md. Minhajur Rahman
Ranch Hand

Joined: Apr 10, 2012
Posts: 33
Hi Henry Wong, Thanks a lot.

.
.
I can however, speculate. I think negative years are BC (before Christ) years. So the printout is actually for the year 2011 BC !! .... Now a little trivia. There is no such a thing as year zero. It goes from year 3 BC to year 2 BC to year 1 BC to year 1 AD to year 2 AD, etc. And since there is no such a thing as year zero, I am going to speculate that 0 maps to year 1 BC, -1 maps to year 2 BC, -2 maps to year 3 BC, etc.

Really Great!!! Really I am learning a lot from this forum. Also Thanks to K&B. I was trying following their advice to "Code,Code,Code" and kind of thinking : "what if i change it as like..... ". Thanks all who are devoted in this forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need Help in understanding DateFormat.parse()
 
Similar Threads
back ground process id ??
How to identify Auth method NTLMv1 or NTLMv2
my maven test fails after i do a mven clean from eclipse and try to build it again
Formating a Date
SEVERE: BAD packet signature 200,SEVERE: Caught exception (java.lang.NullPointerException)