aspose file tools*
The moose likes Beginning Java and the fly likes date to string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "date to string" Watch "date to string" New topic
Author

date to string

Janardan Kelkar
Ranch Hand

Joined: May 05, 2008
Posts: 72

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..


When the compiler's not happy, ain't nobody happy.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36508
    
  16
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

    Joined: May 05, 2008
    Posts: 72

    k....thanks
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 36508
        
      16
    You're welcome
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: date to string
     
    Similar Threads
    String conversion
    Update more than one rows through one Submit/Update Button
    Date difference
    first date and last date of month
    compare dates which are in string variable in javascript