• Post Reply Bookmark Topic Watch Topic
  • New Topic

Date format  RSS feed

 
Maureen Charlton
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I have the following date format:

SimpleDateFormat year = new SimpleDateFormat("yyyy")

and I have a date coming in as:

"0182" which is month 01 and year 82

Can I actually use DateFormat? Or am I forced to use the GregorianCalendar?

I use the word forced as all my other validations have been in the DateFormat and I wanted to be consistent, if possible.
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could always parse the last two digits, prepend "19" or "20" as appropriate, then pass it into the SimpleDateFormat constructor. Both String and StringBuffer have excellent utilities for doing this...
 
Maureen Charlton
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff,

Many thanks for your response. Makes sense.

 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!