Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

convert String to Date  RSS feed

 
Peter Guillebaud
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know how to do this for multiple dates if the date Strings are of variable lengths? I think the SimpleDateFormat class should help but how can it be done when one date String is August 31, 2001 14:00 GMT and another September 18, 2001 23:00 GMT ? The format is the same but the number of letters for each month changes!! I need to change it to format yyyy-mm-dd.
Thanks in advance.

 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The length doesn't matter you tell it what format the String is in and the parse method takes care of the details.
 
Chad McGowan
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use this SimpleDateFormat string
 
Peter Guillebaud
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much, that works perfectly.
 
How do they get the deer to cross at the signs? Or to read this tiny ad?
Thoughts on deprecation in Java
https://coderanch.com/t/683016/java/Deprecation-Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!