Converting time stamp recived to different format

LegacyForumLegacyForum Posts: 1,669 ✭✭
edited December 2016 in SOAtest
converting time stamps
Hi Parasoft,

I have a method that when called returns date/time stamps as follows:

2004-06-26T12:21:11.0000000-04:00

I would like to use that date/time in an XML Databank but the format is not allowed by my system. Do you guys have a way that I can convert it to the following format:

2004-06-26T12:21:11.778Z

Thanks,
Beth
Tagged:

Comments

  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    Beth,

    Hi Beth. What do the numbers after the "." stand for in your time stamps? For example the "0000000-04:00" and "778Z". Do they specify the time zone? If so, I would assume that the time zone would stay constant and you would be able to use a script like the following to convert the format.

    CODE
    from com.parasoft.api import *
    from java.lang import *

    def dateConversion(input, context):
     date = String("2004-06-26T12:21:11.0000000-04:00")
     newDate = date.substring(0, date.indexOf("."))
     newDate = newDate + ".778Z"
     return newDate
Sign In or Register to comment.