string to date


I need to converti a string to date (my region is UTC+2)

out_X= new SimpleDateFormat(dateFormat).parse("20140516");

print: Fri May 16 00:00:00 CEST 2014 that is converted into 2014-05-15T22:00:00.0

Now i add two hours:

public static Date Date2(Date d){
 Calendar cal = Calendar.getInstance();
 cal.add(Calendar.HOUR, 2);
 return cal.getTime();

print: Fri May 16 02:00:00 CEST 2014 that is converted into 2014-05-16T00:00:00.0

It works =)

Now i try with these:

out_X = Date2(new SimpleDateFormat(dateFormat).parse("20140216"));
logger.warn("Riferimento_Date 20140216 "+out_RIFERIMENTODATE);
out_X = Date2(new SimpleDateFormat(dateFormat).parse("20140516"));
logger.warn("Riferimento_Date 20140516 "+out_RIFERIMENTODATE);


Sun Feb 16 02:00:00 CET 2014

Fri May 16 02:00:00 CEST 2014


Why one is CEST and one in CET?



Because February is still winter time whereas may is in summer.

Why don't you use the String to Date/Time node?

With String to Date/Time node works but i prefere to use a java snippet.

I have 7 columns with date and take too much time the execution of 7 nodes.

I have try to force the hour to 0 and to parse directly the string "20140216CEST" but at the console i see always CET. Seem that the conversion node is the only way.