on 07-28-2015 12:42 PM
Hi Gurus,
Request to help me to get a proper UDF for converting TimeZOne from EST to PDT.
i have followed the below link by ENG
but getting below error
Can any one help me how to resolve this or please provide me any UDF which will help me out .
Appreciate your help.
Regards,
Yugandhar.
it might be a typo. can you remove empty spaces and lines above 'public string convertTimeZone'?
Regards,
Nikhil Bose
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
code seems to be fine.
Did you follow these steps
Prerequisite:
Download the library files for Joda-Time from Joda-Time's repository.
Import JAR file into an Imported Archive object.
Add Imported Archive in Archives Used section of Message Mapping or Function Library.
Please paste the code which you have declared?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Seems that Issue with the function name/variable names that you have given. Please assign as convertTimeZone.
Also needs to add library files of Joda-times which is different with standard conversion.
Please also try with below logic:
<Library def><import java.util/text.*;>
Calendar timeDef = new GregorianCalendar();
int a1 = DateFormat.SHORT;
int b1 = DateFormat.SHORT;
String dtEST = DateFormat.getDateTimeInstance(a1,b1).format(timeDef.getTime())+" EST";
time.setTimeInMillis(timeDef.getTimeInMillis()- 60*60*3000);
String dtPST = DateFormat.getDateTimeInstance(a1,b1).format(timeDef.getTime())+" PST";
System.out.println(dtEST+"\n"+dtPST);
Regards,prasanth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.