on 05-08-2023 5:43 PM
Hi All,
Need some mapping logic to display UTC date in one field and UTC Time in another field. Please let me know how to implement logic in PO .
Thanks in advance,
Jeevitha
jeevi3
You can use a user-defined function (UDF) to convert the UTC date and time into separate fields
1. Here is an example of a UDF that converts a UTC date into a separate field:try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date date = sdf.parse(var1[0],new ParsePosition(0));
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, var2[0]);
date = cal.getTime();
String output = sdf.format(date);
result.addValue(output);
} catch (Exception e) {
throw new StreamTransformationException(e.getMessage());
}
This UDF takes two input parameters: the UTC date and the number of days to add or subtract from the date. It then converts the UTC date into a Java Date
object, adds or subtracts the specified number of days, and formats the resulting date as a string in the format yyyyMMdd
. The resulting string is then added to the output field.
You can modify this UDF to convert the UTC time into a separate field by using the SimpleDateFormat
class to format the time as a string in the desired format.
I hope this helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.