• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

date to string

 
Janardan Kelkar
Ranch Hand
Posts: 72
Eclipse IDE Firefox Browser Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i get the current system date, and convert it to string, example, i want to generate the following string:
"28/08/2008"

i tried using calendar class and all, but have not been able to still figure it out properly..
 
Campbell Ritchie
Sheriff
Pie
Posts: 49793
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At least two ways to do it:
  • You can use the SimpleDateFormat class or similar and use that to format the output.
  • Use the tags of the Formatter class, which reappear in several locations
  • Example of the latter: String.format("%Td/%<TB/%<Ty", myDate) which won't give the format you are asking about.
     
    Janardan Kelkar
    Ranch Hand
    Posts: 72
    Eclipse IDE Firefox Browser Suse
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    k....thanks
     
    Campbell Ritchie
    Sheriff
    Pie
    Posts: 49793
    69
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    You're welcome
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic