on 11-28-2017 1:29 PM
hi,
I have a requirement where incoming time will be (08:30:00.000+01:00) and I need to send output as 09:30:00
I need udf to convert GMT to CET .
Any help ?
Thanks,
Sahana
In short, you can create an UDF using Java SimpleDateFormat. Bear in mind that when converting, you can eventually have to change the day (in case that you also have one field specifically for date)
The code should be something like this:
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss.sss X"); //X is the ofrmat you are using at your example
//Initial timezone.
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
//Target timezone
sdf.setTimeZone(TimeZone.getTimeZone("CET"));
//Will set CET Timezone
System.out.println(sdf.format(calendar.getTime()));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.