• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need Help in understanding DateFormat.parse()

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
ice is for people that are not already cool. Chill with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic