Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date Format

 
Lim Youjie
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

may i know how to change the date format to CST of the Date object?

thanks.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Date class has no concept of timezones. You will need to use the Calendar class.
 
Guy Allard
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you require a Timezone aware date implementation you might want to evaluate:

Joda Time

Regards, Guy
 
Joni Salonen
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can set the time zone of a DateFormat object by using the setTimeZone method: http://java.sun.com/j2se/1.5.0/docs/api/java/text/DateFormat.html
For example:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic