Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

writing file name as date/time  RSS feed

 
Stephanie Lee
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying writing to an output file and want to can the file something similar to fileMMDDYYTIME. i'm not sure how to do that..if anyone can help..that'd be great!
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want a java.util.Date to represent a particular date/time, and then a DateFormat (specifically a SimpleDateFormat) to convert that Date into a String. E.g.

Pay attention to the difference between upper and lower case when you create a SimpleDateFormat - each symbol can mean something different.
If you need a Date other than the time right now, you may find a GregorianCalendar useful for manipulating dates according to whatever rules you devise. But that gets a bit more complex, so we won't go there unless you need to.
[ January 22, 2004: Message edited by: Jim Yingst ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!