• Post Reply Bookmark Topic Watch Topic
  • New Topic

SimpleDateFormat  RSS feed

 
raj majety
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to convert a 1 digit year to 4 digit year. Can some one help me?
I can give an example:
If I type in 6/9/4 the result should be 06/09/2004 instead of 06/09/0004 (SimpleDateFormat by default does 0004).
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rm, welcome to Javaranch. We don't have a lot of rules here, but we do ask that our members use realistic looking names. Please change your moniker accordingly, and you'll find that people are happy to help.

All best,
M
 
raj majety
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did change my name. Now do I have to post the message again? Thanks
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you don't have to repost again.



HTH,
M
 
raj majety
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the code. The code snippet that you send does change the year to 4 digit year but the century it defaults to is not what I want.
Current result:

dateString=:06/09/0004

I want the result to be:

dateString=:06/09/2004
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wasn't careful. Try the following. Notice that there are two ways given.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!