Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Converting time stamp recived to different format

Options
LegacyForum
LegacyForum Posts: 1,664 ✭✭
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

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Options
    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