File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

printf for dates "Date/Time Conversions"

 
Nick Widelec
Ranch Hand
Posts: 226
Eclipse IDE Firefox Browser Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From here it is a little unclear how to format dates with printf.

Is anybody comfortable in using them and does not mind listing a few examples with the 3 categories they list in the above javadoc? (time, date, time/date)

PS: They are not listed in the objectives explicitly.. but as far as I understood you can never assume anything with this exams.
Thanks in advance.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33703
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nick,
I always use SimpleDateFormat to print dates so I've never used printf for them. Consider these two pieces of code. Which is easier to read? I think the second is by a landslide. (This is an example from the link you gave - I just made the SimpleDateFormat example.)





As far as the exam, the most common printf flags are on it. The objectives lists which flags you need to know. None of which are date/time flags.
 
Nick Widelec
Ranch Hand
Posts: 226
Eclipse IDE Firefox Browser Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for responding, I have a basic understading of 't' plus anycombination, however there are many conversions character like the following:

'R' Time formatted for the 24-hour clock as "%tH:%tM"
'T' Time formatted for the 24-hour clock as "%tH:%tM:%tS".
'r' Time formatted for the 12-hour clock as "%tI:%tM:%tS %Tp". The location of the morning or afternoon marker ('%Tp') may be locale-dependent.
'D' Date formatted as "%tm/%td/%ty".
'F' ISO 8601 complete date formatted as "%tY-%tm-%td".
'c' Date and time formatted as "%ta %tb %td %tT %tZ %tY", e.g. "Sun Jul 20 16:17:00 EDT 1969".


which I have not been able to see examples of.

I really hope that they won't be in the exam.. otherwise would be a memery checking test.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33703
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nick Widelec wrote:I really hope that they won't be in the exam.. otherwise would be a memery checking test.

When I took the exam, there weren't any questions of this sort so I'm inclined to trust them on which formatting types are covered.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic