• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

formatting a string (that is secretly a date) yet as a string...

 
Matt Horton
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this the 'proper' way to do this:

Is there a way for me to bypass making a date object, or a better way to convert b/w dates and strings?
Thanks in advance.
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The SimpleDateFormat is the easiest way to convert between Dates and Strings, but what you have posted won't give you the results desired:

What you want is something like the convertDate funtion below:
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you were just hell-bent on not making a Date object, you could write your own formatter using regular expressions and/or a few String.substring() and String.charAt() invocations.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic