webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  date conversion from GMT to EST

    Posted Wed January 03, 2018 04:17 PM

    Hi All,

    I am trying to convert the date from GMT to EST , I am using 9.6 version

    Example 2017-12-21 18:00:000Z to 2017-12-21T 13:00:00.0 05:00 can please let me know the best way to get the results

    Thanks


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 2.  RE: date conversion from GMT to EST

    Posted Thu January 04, 2018 09:06 AM

    Hi,

    when you transform the first value to a Date-Object, you can use the Built-In service pub.date:formatDate to get the value in the timezone specified.

    Please note that using the abbrevations for timezone codes is deprecated due to ambiguosity.
    Better use the numeric offset [+|-]xx:yy instead. Unfortunaley Java omits the colon separator between hours and minutes which leads to issues when using such values in XML fields defined as xsd:datetime-type.

    Regards,
    Holger


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 3.  RE: date conversion from GMT to EST

    Posted Thu January 04, 2018 12:16 PM

    I had a similar requirement a while ago so I wrote my own version of dateTimeFormat that also takes in the desired timezone as input. Here’s the code:

    
    IDataCursor cursor = pipeline.getCursor();
    String inString = IDataUtil.getString( cursor, "inString" );
    String currentPattern = IDataUtil.getString( cursor, "currentPattern" );
    String newPattern = IDataUtil.getString( cursor, "newPattern" );
    String timezone = IDataUtil.getString( cursor, "timezone" );
    SimpleDateFormat format = new SimpleDateFormat( currentPattern );
    format.setLenient(false);
    Date currentDate;
    try
    {
    currentDate = format.parse(inString );
    }
    catch( Throwable t )
    {
    cursor.destroy();
    throw new ServiceException(t);
    }
    format = new SimpleDateFormat(newPattern);
    format.setTimeZone(TimeZone.getTimeZone(timezone));
    String value = format.format(currentDate);
    IDataUtil.put(cursor, "value", value);
    cursor.destroy();

    By the way, Java does support time zone offsets in the ISO8601 format now, including the colon. Check out: SimpleDateFormat (Java Platform SE 8 )

    Using your example, you could call the service with the following inputs:

    inString: 2017-12-21T13:00:00.000-00:00
    currentPattern: yyyy-MM-dd’T’HH:mm:ss.SSSXXX
    newPattern: yyyy-MM-dd’T’HH:mm:ss.SSSXXX
    timezone: GMT-5

    And the service returns: 2017-12-21T08:00:00.000-05:00

    Good luck,
    Percio


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 4.  RE: date conversion from GMT to EST

    Posted Thu January 04, 2018 01:47 PM

    Hi Percio,

    the ISO8601-Timezone pattern has been introduced with Java 7.

    Should be working in webMethods 9.x and newer.

    Thanks for pointing the link to Oracle documentation.

    Regards,
    Holger


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 5.  RE: date conversion from GMT to EST

    Posted Thu January 04, 2018 03:18 PM

    You’re welcome. I have a 9.6 instance on my laptop and it came with Java 7 so S S should be able to use XXX.

    Percio


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods