This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how can i reformat a Date object

 
netanel weinberg
Greenhorn
Posts: 27
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Intermediate forum...
 
Ankur Srivastava
Ranch Hand
Posts: 62
  • 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
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur Srivastava was right.

[ August 01, 2004: Message edited by: Jack Kay ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic