Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
HI,
I have a column with strings like "2019-03-17 06:15:00 +0400". How can I add +0400 into the time? For example "2019-03-17 10:15:00"
Thanks a lot .
This is all about timezones and it can get very confusing. But essentially, what you appear to be wanting to do is to use UTC as your timezone. There are a couple of methods that Talend provide for this, but first you need to know how your data is being stored. If it is being stored as a String, then it is relatively easy. You can use code similar to below.....
String myDate = "2019-03-17 06:15:00 +0400"; Date d = routines.TalendDate.parseDate("yyyy-MM-dd HH:mm:ss X", myDate); System.out.println(myDate); System.out.println(routines.TalendDate.formatDateInUTC("yyyy-MM-dd HH:mm:ss", d));
The code above outputs (to the System.out) your date as a UTC date in String form. Copy and paste this code into a tJava and you will see what I mean.
This is all about timezones and it can get very confusing. But essentially, what you appear to be wanting to do is to use UTC as your timezone. There are a couple of methods that Talend provide for this, but first you need to know how your data is being stored. If it is being stored as a String, then it is relatively easy. You can use code similar to below.....
String myDate = "2019-03-17 06:15:00 +0400"; Date d = routines.TalendDate.parseDate("yyyy-MM-dd HH:mm:ss X", myDate); System.out.println(myDate); System.out.println(routines.TalendDate.formatDateInUTC("yyyy-MM-dd HH:mm:ss", d));
The code above outputs (to the System.out) your date as a UTC date in String form. Copy and paste this code into a tJava and you will see what I mean.