on 2010 Oct 07 11:14 AM
Hi ,
I would like to convert the time retrieved from the database to UTC format. Do you have any idea how this possible in MII?
Is there any inbuilt method in MII for doing this
Thanks
Shaji
Request clarification before answering.
Hello Shaji,
in my opinion a real time zone conversion cannot be achieved by using the MII functions and standard actions. I wrote my own MII action. It looks something like this:
private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
@Action(name = "TimeZoneConverter")
@Outputs(names = { "OutputDate" }, types = { VariantDataTypes.STRING })
public boolean run(IActionInstance action,
@Input(name = "InputTimeZone") String inputTimeZone,
@Input(name = "InputDate") String inputDate,
@Input(name = "OutputTimeZone") String outputTimeZone)
throws InvalidVariableException, DataConversionException {
SimpleDateFormat inputDateFormat = new SimpleDateFormat(DATE_FORMAT);
inputDateFormat.setTimeZone(TimeZone.getTimeZone(inputTimeZone));
Date date = inputDateFormat.parse(inputDate);
SimpleDateFormat outputDateFormat = new SimpleDateFormat(DATE_FORMAT);
outputDateFormat.setLenient(true);
outputDateFormat.setTimeZone(TimeZone.getTimeZone(outputTimeZone));
action.setActionResult("OutputDate", outputDateFormat.format(date));
return true;
}
Regards,
Martin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Shaji,
you may google a bit to find possibilities to convert the time directly in your query. For example, if you use Oracle you may call [NEW_TIME|http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions092.htm] function to convert a time to another timezone.
Inside MII, the workbench offers some nice [Date functions|http://help.sap.com/saphelp_mii121/helpdata/en/43/e80b59ad40719ae10000000a1553f6/frameset.htm] you may use to get your UTC date from a given date. For example, add an amount of time to your date using datediffhours/datediffminutes etc.
Michael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
6 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.