• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

date format

 
ben oliver
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Date today = new Date();
SimpleDateFormat df = new SimpleDateFormat("MM/DD/yyyy");
System.out.println("today is " + df.format(today));

I got

today is 04/98/2008

instead of

today is 04/07/2008


what is wrong ??
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the SimpleDateFormat javadoc
D Day in year Number
d Day in month Number
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
then it should be like that.



These following pattern letters are defined in Java Docs (characters from 'A' to 'Z' and from 'a' to 'z' are reserved to do specific presentation).
 
ben oliver
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic