on 11-16-2007 2:04 PM
Hi,
I need following date formats filled by the graphical mapping tool:
1. I want the current date in format 2007-10-01T11:57:45.147562Z
2. The local date 2007-10-01T11:57:45.147562Z time zone ETC should be changed to UTC
Could anyone provide a user defined function (UDF) for this?
Best regards
Stefan
Hi Stefan,
I have recently made this User Defined Function, which calls a UTCLocalConverter class
UTCToLocal
Imports:com.sap.aii.mapping.api.AbstractTrace;nl.gasunie.pi.mapping.utils.date.UTCLocalConverter;com.sap.aii.mapping.api.StreamTransformationException;
//write your code here
String localDateTime = null;
try {
UTCLocalConverter converter = new UTCLocalConverter();
localDateTime = converter.getLocalDateTime(utcDateTime, dateFormat);
} catch (Exception e) {
AbstractTrace trace =container.getTrace();
trace.addWarning(e.getMessage());
}
return localDateTime;
Class UTCLocalConverter
package nl.gasunie.pi.mapping.utils.date;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
/**
@author ex23257
*/
public class UTCLocalConverter {
private String utcDateTime;
private String localDateTime;
private String dateTimeFormat;
private int calculateOffSet() {
Calendar cal = Calendar.getInstance();
TimeZone timeZone = cal.getTimeZone();
int offSet = timeZone.getRawOffset();
return offSet;
}
private void setLocalDateString(String utcDateTime, String dateTimeFormat)
throws Exception {
try {
SimpleDateFormat dataFormat = new SimpleDateFormat(dateTimeFormat);
Date utcDate;
utcDate = dataFormat.parse(utcDateTime);
Calendar cal = Calendar.getInstance();
cal.setTime(utcDate);
cal.setTimeInMillis(cal.getTimeInMillis() + calculateOffSet());
Date localDate = cal.getTime();
this.localDateTime = dataFormat.format(localDate);
} catch (Exception e) {
throw new Exception(
"Error in Class UTCLocalConverter.setLocalDateString: "
+ e.getMessage());
}
}
/** Converts a UTC date time string to local time.
example:
UTCLocalConverter converter = new UTCLocalConter();
String localDateTime = converter.getLocalDateTime( "2007-12-31 12:46:69","yyyyMMdd HH:mm:ss" );
*/
public String getLocalDateTime(String utcDateTime, String dateTimeFormat)
throws Exception {
try {
setLocalDateString(utcDateTime, dateTimeFormat);
} catch (Exception e) {
throw new Exception(e.getMessage());
}
return localDateTime;
}
}
Maybe this help you.
Regards Sander
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Stefan,
What is your input date format? Could you please give us the sample input you are getting inside UDF.
raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check below links for UDF's
http://flickr.com/photos/8764045@N06/
Example 1
http://www.flickr.com/photo_zoom.gne?id=544183191&size=o
http://www.flickr.com/photo_zoom.gne?id=544183195&size=o
http://www.flickr.com/photo_zoom.gne?id=544183225&size=o
http://www.flickr.com/photo_zoom.gne?id=544183233&size=o
Example 2
http://www.flickr.com/photo_zoom.gne?id=545133789&size=o
http://www.flickr.com/photo_zoom.gne?id=545133791&size=o
http://www.flickr.com/photo_zoom.gne?id=545133801&size=o
http://www.flickr.com/photo_zoom.gne?id=545133807&size=o
http://www.flickr.com/photo_zoom.gne?id=545133811&size=o
http://www.flickr.com/photo_zoom.gne?id=545138911&size=o
http://www.flickr.com/photo_zoom.gne?id=545138913&size=o
http://www.flickr.com/photo_zoom.gne?id=545138915&size=o
http://www.flickr.com/photo_zoom.gne?id=545138917&size=o
http://www.flickr.com/photo_zoom.gne?id=545138947&size=o
http://www.flickr.com/photo_zoom.gne?id=545138951&size=o
http://www.flickr.com/photo_zoom.gne?id=545005958&size=o
Example 3
http://www.flickr.com/photo_zoom.gne?id=549186611&size=o
http://www.flickr.com/photo_zoom.gne?id=549186651&size=o
http://java.sun.com/j2se/1.5.0/docs/api/
/people/krishna.moorthyp/blog/2006/07/29/documentation-html-editor-in-xi
/people/sap.user72/blog/2006/02/06/xi-mapping-tool-exports
http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm
/people/stefan.grube/blog/2005/12/30/test-user-defined-functions-for-the-xi-graphical-mapping-tool-in-developer-studio
http://help.sap.com/bp_bpmv130/Documentation/Operation/MappingXI30.pdf
Regards,
Phani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.