• Post Reply Bookmark Topic Watch Topic
  • New Topic

Date Issue in Java 1.5  RSS feed

 
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code produces the below output:



output: 10/1/07

The issue here is, shouldn't it be 10/1/2007.

Is there a way to get it in mm/dd/yyyy format?
 
lowercase baba
Bartender
Posts: 12582
50
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know, i'm taking a stab here. the api says:

getDateInstance
public static final DateFormat getDateInstance(int style)Gets the date formatter with the given formatting style for the default locale.

to me, this sounds like it's using the format defined somewhere else, maybe by your OS?
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I give DateFormat.MEDIUM it is printing Oct 1, 2007

For "MEDIUM" it is printing 2007 fully.
 
Sheriff
Posts: 21185
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at java.text.SimpleDateFormat.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!