Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SimpleDateFormat

 
Gobind Singh
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I format a date to get a string of the following format:

dd.m.y

I have tried SimpleDateFormat sdf = new SimpleDateFormat("dd.M.y");
and sdf.format(myDate);

This returns a string of the format dd.m.yy

I dont want the 2 digit year. I only want the last digit of the year e.g. for 2007 I want 7.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15281
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think SimpleDateFormat supports formatting only 1 digit of the year. Why do you want to do it like that - it's very unusual to use only 1 digit for the year, and in three years time it will be 2010, what output do you want then - "0" or "10"?

You'll have to do this manually (without SimpleDateFormat) if you really want to do this.
 
Gobind Singh
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i totally agree with you. Its a business requirement to output the date in that format.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic