cancel
Showing results for 
Search instead for 
Did you mean: 

Converting to UTC time format

shaji_chandran
Participant
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

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