Search code examples
hibernatejsfweb-applicationstimezone

Cannot change time zone of java web application


I have web application with me. It is showing US time. I want it to show Indian time. I have tried setting property uing System.getProperty().setProperty("user.country","IN"); and System.getProperty().setProperty("user.variant","IN"); but still it is showing use time.

I even tried Locale.setDefault(new Locale("en", "IN")); but in vain.

When I do this

SimpleDateFormat format = new SimpleDateFormat("yyyyy.MMMMM.dd GGG hh:mm aaa -- z");
System.out.println("Date: "+format.format(new Date())); 

The result is Date: 02013.March.14 AD 12:29 AM -- GMT-08:00. what am I doing wrong.

It is a JSF 1.1 and Hibernate 3 project deployed in tomcat 6.

Thanks in advance.


Solution

  • Add this line:

    format.setTimeZone(TimeZone.getTimeZone("IST"));