Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need Help in understanding DateFormat.parse()

 
Md. Minhajur Rahman
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The output of the following snippet is Wed Jan 13 00:00:00 BDT 2011. But why, please anyone help...
 
Henry Wong
author
Marshal
Pie
Posts: 21506
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Md. Minhajur Rahman
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic