• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how can i reformat a Date object

 
netanel weinberg
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
i have a date object with date details and i want to reformat it from yyyyy-MM-dd format to dd/MM/yyyy format how can i do it?

10x ahead,
netanel
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Intermediate forum...
 
Ankur Srivastava
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should use java.text.SimpleDateFormat class for your purpose.
 
Jack Kay
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright, import Date & DateFormat:


Now you'll create a Date & DateFormat object:


Now you'll format the Date with the DateFormatter:


The closest I could get you was to dd/MM/yy

I'll research around to find the answer!
[ August 01, 2004: Message edited by: Jack Kay ]
 
Jack Kay
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur Srivastava was right.

[ August 01, 2004: Message edited by: Jack Kay ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic