• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

!SimpleDateFormat

 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This works:

But trying to set the date to something tells me I am using deprecated methods.
So I try and use GregorianCalendar but than I don't know how to get back to SimpleDateFormat or DateFormat to be able to print it out as "Month Day Year".
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The three lines of code you have posted do not give any compile warnings and work as anticipated. Did you leave out some other code? Just for reference, this is how you get a date object from a Calendar/GregorianCalendar object:

Jamie
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I stated that the code I posted worked.
You answered my question when you showed me how to get the 'date' object using 'getTime()', thanks.
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And I quickly notice that month 1 is February, not January. Wow that is dumb.
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Barnes:
And I quickly notice that month 1 is February, not January. Wow that is dumb.
yeah, I used to catch myself doing that too. So, now I exclusively use the static field Calendar.DECEMBER... etc to avoid forgetting.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the old array issue... create an array of month names and then use the month to get them. If the month is 1-12 then you have to subtract one. Since the months are 0-11, you don't have to subtract one. I'm sure Java does this because all the other languages do it.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic