Skip to Content
avatar image
Former Member

Help with DateTrans function YYYY-MM-DDTHH:MM:SS.sssZ

I am trying to map a datetime field supplied by a call from Sybase Unwired Platform.

It is sending the date as format 2011-11-15T15:10:13.944Z and I am trying to use the Datetrans function to convert to the 20111115 required by an IDOC date field.

I am using

yyyy-dd-MMTHH:mm:ss.SSS

as the input format but it fails with runtime error Illegal pattern character 'T'

Can anyone help ?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Nov 17, 2011 at 02:33 PM

    hi,

    Use the standard function "DateTrans", and see mainly this Java help, you will know exactly all the possibilities:

    be careful on lowercase and ippercase, because the mean is different !

    [http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html] (really good, )

    [http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html]

    [http://java.sun.com/j2se/1.5.0/docs/api/java/text/DateFormat.html]

    Example: (not yours)

    yyyy.MM.dd G 'at' HH:mm:ss z --> 2001.07.04 AD at 12:08:56 PDT

    so with a text 'at'...

    I'm sure you will have yours. Enjoy play.

    regards.

    Mickael

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 17, 2011 at 02:35 PM

    Here is the udf to achieve this

    create a udf function with input as parameter and pass the date string and return as string

    Signature Variable

    Type Argument    Name input  JavaType String
    
    public String datesString(String input, Container container) throws StreamTransformationException{
    
    	String input = "2011-11-15T15:10:13.944Z ";
    	String parseDateString = input.substring(0,10);
    	StringBuffer output = new StringBuffer().append(parseDateString.substring(0,4))
                                                                   .append(parseDateString.substring(5,7))
                                                                   .append(parseDateString.substring(8,10));
    			
                             return output.toString();
    
    }

    Edited by: Baskar Gopal on Nov 17, 2011 9:36 AM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 17, 2011 at 03:37 PM

    Thank you all

    Mickael's link gave me the answer in needed.

    I Used the dateTrans function with input format yyyy-MM-dd'T'HH:mm:ss.SSS'Z' and it converted beautifully.

    Paul

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 17, 2011 at 01:48 PM

    with the standard datetrans function, i dont think the format YYYY-MM-DDTHH:MM:SS.sssZ is supported.

    you might have to write a simple UDF to help you out here for the date conversion.

    Add comment
    10|10000 characters needed characters exceeded