• Post Reply Bookmark Topic Watch Topic
  • New Topic

Date Issue in Java 1.5  RSS feed

 
Vishnu Prakash
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?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
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.
 
Rob Spoor
Sheriff
Posts: 21095
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at java.text.SimpleDateFormat.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!