Java 更改Tomcat 7应用程序上的时区-Openshift

Java 更改Tomcat 7应用程序上的时区-Openshift,java,tomcat7,openshift,Java,Tomcat7,Openshift,我在openshift(免费版)上部署了一个web应用程序,一直在努力修复时区,但运气不佳。我的时区是“亚洲/科伦坡”。我该怎么做 我的应用程序托管在ApacheTomcat7服务器上 // gives me current date from server time zone java.util.Date date = new Date(); // However for now I manage to fix the issue with below code //

我在openshift(免费版)上部署了一个web应用程序,一直在努力修复时区,但运气不佳。我的时区是“亚洲/科伦坡”。我该怎么做

我的应用程序托管在ApacheTomcat7服务器上

   // gives me current date from server time zone
   java.util.Date date = new Date();

   // However for now I manage to fix the issue with below code
   // without having to change it from server side.
   public static Date getNormalizedDate() {

     Calendar today = Calendar.getInstance(TimeZone.getTimeZone("Asia/Colombo"));
     Calendar cal = Calendar.getInstance();

     cal.set(Calendar.DATE, today.get(Calendar.DATE));
     cal.set(Calendar.MONTH, today.get(Calendar.MONTH));
     cal.set(Calendar.MONTH, today.get(Calendar.MONTH));
     cal.set(Calendar.HOUR_OF_DAY, today.get(Calendar.HOUR_OF_DAY));
     cal.set(Calendar.MINUTE, today.get(Calendar.MINUTE));
     cal.set(Calendar.SECOND, today.get(Calendar.SECOND));

     return (cal.getTime());
  }

显示时区错误的代码问题到底是什么?你得到了什么结果?你期望什么?