aspose file tools
The moose likes Java in General and the fly likes SimpleDateFormat Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "SimpleDateFormat" Watch "SimpleDateFormat" New topic
Author

SimpleDateFormat

Gobind Singh
Ranch Hand

Joined: Aug 04, 2006
Posts: 60
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
Bartender

Joined: Aug 16, 2005
Posts: 12929
    
    3

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Gobind Singh
Ranch Hand

Joined: Aug 04, 2006
Posts: 60
i totally agree with you. Its a business requirement to output the date in that format.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: SimpleDateFormat
 
Similar Threads
SimpleDateFormat problem with 2-digit year
Extracting year in MM/dd/yyyy
SimpleDateFormat
internationalization - date format
date format