Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Time Zone Z associated with date

 
prince davies
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IN xsd date is represented like <endDateTime>2011-08-02Z</endDateTime>

if you look closer you see "z" associated with the date.



When i use format method to get string ,it will return me correct data.
but when i convert date string to date ,it returns me wrong date ,

format = August 2, 2011
parse = august 01.2011

how do i resolve this issue?
 
prince davies
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need this method should return date object and date should be standardized one or it should be accordance with the date stored in database (time zone)
 
prince davies
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

public String formatGMTDate(Date date) {

String result = " ";
if (date != null) {
SimpleDateFormat gmtFormat = new SimpleDateFormat(DATE_FORMAT, getLocale());
TimeZone gmtTime = TimeZone.getTimeZone("GMT");
gmtFormat.setTimeZone(gmtTime);
result = gmtFormat.format(date);
}
return result;
}[/code]

or
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic