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
Expand all | Collapse all

COnverting java.lang.string to java.sql.timestamp

  • 1.  COnverting java.lang.string to java.sql.timestamp

    Posted Thu November 29, 2012 02:56 AM

    Hi Forum,

    I need to write a java service where java.lang.string needs to be converted to java.sql.timestamp.

    Need to do two things:

    1.Change the “Input Field Type” of DATE column from java.lang.String to java.sql.timestamp in the adapter service
    2.Converting date string to a java.sql.timestamp object prior to invoking the adapter service""

    [SIZE=2]
    Please mail me at parvati.preeta@gmail.com

    or kindly reply to the post

    Thanks,
    Preeta
    [/SIZE]


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


  • 2.  RE: COnverting java.lang.string to java.sql.timestamp

    Posted Thu November 29, 2012 04:48 PM

    in java code, you can use: java.text.SimpleDateFormat

    SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss.SSS”);

    Timestamp sqlTime= new Timestamp(sdf.parse(TheTimeString));


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


  • 3.  RE: COnverting java.lang.string to java.sql.timestamp

    Posted Fri November 30, 2012 05:48 AM


  • 4.  RE: COnverting java.lang.string to java.sql.timestamp

    Posted Sat March 12, 2016 08:49 AM

    Timestamp sqlTime= new Timestamp(sdf.parse(TheTimeString));

    == www.solitaire-champ.com ==


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


  • 5.  RE: COnverting java.lang.string to java.sql.timestamp

    Posted Mon March 14, 2016 11:14 AM

    Hi,

    you can use the built-in service “formatDate”. you need to map the date and date pattern.

    Regards,
    Naga.


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


  • 6.  RE: COnverting java.lang.string to java.sql.timestamp

    Posted Mon March 14, 2016 12:54 PM

    Hi,

    if the build in service “pub.date:formatDate” is not available in WmPublic package,
    you might want to have look at the WmTransformationServices package or the PSUtilities packagae (both available from the download section of the community).

    At least one of them contains a service your are looking for.

    Remember to change the input field of your Adapter Service to java.util.Date instead of java.lang.String or java.sql.Timestamp. It will be automatically mapped to Database datatype TIMESTAMP by the Adapter.

    Regards,
    Holger


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


  • 7.  RE: COnverting java.lang.string to java.sql.timestamp

    Posted Mon March 14, 2016 01:07 PM

    Looks like a old post, but pub.date:formatDate exists in WmPublic. I am on v98, I just used it today :slight_smile:


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


  • 8.  RE: COnverting java.lang.string to java.sql.timestamp

    Posted Mon March 14, 2016 01:34 PM

    Hi,

    if the WmPublic service is available it is always preferrable to use this one.
    But this does not change the output type:
    It is java.util.Date, not java.sql.Timestamp.

    Indeed this seems to be an older post from 2012.
    I got irritated by latest update Waleed.

    Even by updating older posts with current possibilities this might help the community members to learn about improvements which have been made to code base over time.

    Regards,
    Holger


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


  • 9.  RE: COnverting java.lang.string to java.sql.timestamp

    Posted Mon March 14, 2016 03:30 PM


  • 10.  RE: COnverting java.lang.string to java.sql.timestamp

    Posted Tue May 31, 2016 07:57 PM

    So I could use some help. I am new to webMethods and have been trying to fix an issue for sometime.

    Maybe if you guys had some i/p that would help

    This is the DB table
    Name Null Type


    EVENT_ID NOT NULL NUMBER(20)
    SOURCE VARCHAR2(20)
    TARGET VARCHAR2(25)
    EVENT_DATE DATE

    I am now trying to use the JDBC adapter to insert a row, I have problems with the date column when specifying the input object as a string. See attached image.
    I read through some of the posts and tried to use the to_date function, passing in the string a i/p.

    However I still get the following.

    com.wm.pkg.art.error.DetailedServiceException: [ART.117.4002] Adapter Runtime (Adapter Service): Unable to invoke adapter service ServerLogTest.database:insertIntoEvents.
    IllegalArgument Exception for field: EventE. Error: java.lang.IllegalArgumentException

    I wonder if these is a service for string to java.sql.date conversion


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