Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8451

Re: UDF require to convert Time Zone from EST to PDT

$
0
0

please find the below code which used

 

public String convertTimeZone(String Input_Timestamp, String Timestamp_format, String From_Timezone, String To_Timezone, Container container) throws StreamTransformationException{

 

LibraryMethod(title="convertTimeZone", description="Convert input time from one timezone to another", category="FL_DateTime", type=ExecutionType.SINGLE_VALUE)

public String convertTimeZone ( 

  Argument(title="Input_Timestamp")  String timestamp, 

  Parameter(title="Timestamp_format")  String format, 

  Parameter(title="From_Timezone")  String fromTZ, 

  Parameter(title="To_Timezone")  String toTZ, 

   Container container)

throws StreamTransformationException

  DateTimeFormatter formatter = DateTimeFormat.forPattern(format); 

  DateTimeZone originalTZ = DateTimeZone.forID(fromTZ); 

  DateTime fromDateTime = new DateTime(DateTime.parse(timestamp, formatter), originalTZ); 

  DateTime toDateTime = fromDateTime.withZone(DateTimeZone.forID(toTZ)); 

  return formatter.print(toDateTime); 

}


Viewing all articles
Browse latest Browse all 8451

Trending Articles