Skip to Content
avatar image
Former Member

Converting to UTC time format

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Oct 08, 2010 at 01:08 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 07, 2010 at 11:39 AM

    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

    Add comment
    10|10000 characters needed characters exceeded