Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
prathyush kp
java.util.Date showing wrong current date
January 14, 2009 5:26 AM
Answer

prathyush kp

Rank: New Member

Posts: 11

Join Date: January 14, 2009

Recent Posts

Hi all

I Am not able to get current date by using java.util.Date.

I have set the user.timezone in system.properties as IST(Indian standard Time). Also -Duser.timezone=IST in setenv.bat

But java.util.Date still showing a 5.30 hour lagging. I thing it is still taking GMT only

Am using liferay 5.1.2 and windows machine

Plz help me its urgent
Tobias Gindler
RE: java.util.Date showing wrong current date
January 14, 2009 9:44 AM
Answer

Tobias Gindler

Rank: Junior Member

Posts: 71

Join Date: March 23, 2007

Recent Posts

Hello,

Use the java.util.Calendar class. It will help you.
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html

Best regards

Tobias
prathyush kp
RE: java.util.Date showing wrong current date
January 14, 2009 8:22 PM
Answer

prathyush kp

Rank: New Member

Posts: 11

Join Date: January 14, 2009

Recent Posts

But That too is not workin for me
prathyush kp
RE: java.util.Date showing wrong current date
January 14, 2009 8:28 PM
Answer

prathyush kp

Rank: New Member

Posts: 11

Join Date: January 14, 2009

Recent Posts

Bez date current Date is wrong its effecting Quatz shedular also

Plz help me to get Current date and time in IST(Not GST)
Tobias Gindler
RE: java.util.Date showing wrong current date
January 15, 2009 6:24 AM
Answer

Tobias Gindler

Rank: Junior Member

Posts: 71

Join Date: March 23, 2007

Recent Posts

Hi,

use the following:
1Calendar vCalendar = Calendar.getInstance(TimeZone.getTimeZone("Asia/Calcutta"));
2System.out.println(vCalendar.toString());


The Calendar instance will store the date in IST correctly.
Use the Calendar.get(int field) function to access the day,month,year,... directly.
You can use the java.text.DateFormat with the calendar instance to generate a formatted String.

Don't use the Date class at all, because it is more or less deprecated.

Best regards

Tobias
prathyush kp
RE: java.util.Date showing wrong current date
January 15, 2009 8:45 PM
Answer

prathyush kp

Rank: New Member

Posts: 11

Join Date: January 14, 2009

Recent Posts

Thanks tobias .... Its working fine now. Thank you very much
Sana Afreen Yadgir
RE: java.util.Date showing wrong current date
May 8, 2012 9:25 PM
Answer

Sana Afreen Yadgir

Rank: New Member

Posts: 4

Join Date: May 8, 2012

Recent Posts

Hello,
I have resloved this problem by setenv.bat. The tomcat bundle provided by Liferay contains the setenv.bat inside the bin folder of tomcat.
modified the timezone inside the setenv.bat as
-Duser.timezone=Asia/Calcutta
David H Nebinger
RE: java.util.Date showing wrong current date
May 8, 2012 9:36 PM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7157

Join Date: September 1, 2006

Recent Posts

This is the wrong way to do it.

After logging in you should go to the settings control panel to display settings and set the timezone to use.

Liferay works best running under UTC as it transforms all times from the various possible user timezones to UTC for storage, then converts back to the viewing user's timezone for display.

Setting it in the JAVA_OPTS that way breaks this automated conversion mechanism.
Sana Afreen Yadgir
RE: java.util.Date showing wrong current date
May 10, 2012 1:19 AM
Answer

Sana Afreen Yadgir

Rank: New Member

Posts: 4

Join Date: May 8, 2012

Recent Posts

Hi,
I tried like this also but It was not working.I followed above steps still tomcat server shows same time.That's y I did by setevn.bat file.It's working fine.
Regards,
Sana