Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Locale class  RSS feed

 
sr shashidhar
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi frndz,





OUTPUT:

en_US
1
0
113




OUTPUT :

en_US
1
1
2013

Here, my question is
why we have to add +1 to getMonth() and +1900 to getYear() to retrieve current System date info ..?


thanks in advacne

 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because it says so in the Javadocs of java.util.Date. For getMonth:
The value returned is between 0 and 11, with the value 0 representing January.

For getYear:
Returns a value that is the result of subtracting 1900 from the year that contains or begins with the instant in time represented by this Date object, as interpreted in the local time zone.

But those two methods are deprecated. You should use java.util.Calendar (or JodaTime) if you want to get the current day, month and/or year.
 
sr shashidhar
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:Because it says so in the Javadocs of java.util.Date. For getMonth:
The value returned is between 0 and 11, with the value 0 representing January.

For getYear:
Returns a value that is the result of subtracting 1900 from the year that contains or begins with the instant in time represented by this Date object, as interpreted in the local time zone.

But those two methods are deprecated. You should use java.util.Calendar (or JodaTime) if you want to get the current day, month and/or year.



Thanks Rob Spoor.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!