Wrong dates

Hi all,

First of all, I apologise for posting a request I have already posted in the General Topic section but unfortunately I haven't had any answer.

I really hope you guys can help me.

 

My question is:

When I run a java snippet node like this:

DateFormat f = new SimpleDateFormat("yyyyMMdd");

out_DATE2 = f.parse(c_DATE1);
n.warn("DATE1="+c_DATE1+"------ DATE2="+out_DATE2);

I see:

1) written on the console

DATE1=20110831------ DATE2=Wed Aug 31 00:00:00 CEST 2011

which is exactly what I expected

2) written on the output table

DATE1     DATE2

20110831 2011-08-30T22:00:00.0

which is NOT what I expected.

Could anyone please help me ? Which is the correct statement I have to use ?

I have also noted that forcing the timezone in the snippet like this

TimeZone.setDefault(TimeZone.getTimeZone("GMT"));

has effect also on all the other nodes of all the workflows.

Thanks

nik

The DateAndTimeCell will always assume that dates are in UTC and will display them as UTC. There is currently no way to change this. If you don't care about time zones and just want the dates display "correctly", you need to get an UTC Calendar (e.g Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")), set the date in the calendar and get it back. The returned value should have the correct values but in UTC time.