IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

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

convert a date YYMMDD into Julian format

  • 1.  convert a date YYMMDD into Julian format

    Posted Tue May 29, 2007 12:17 AM

    Hi folks,

    How to convert a date YYMMDD into Julian format?
    Is there any built in service?

    Thanks in Advance,
    Sree


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


  • 2.  RE: convert a date YYMMDD into Julian format

    Posted Tue May 29, 2007 09:22 AM

    Hi Sree-

    I am not sure, we have BIS to convert date values to julian date format…

    Why you cant try with java services?

    1. Create java service with input “date”, “year”, “month” and output “juliandate” - all input, outputs are string.
    2. Once specified the input and output go → Tools–> Generate Code.
    3. and paste your clipboard content to editor…
    4. Modify the code like this…


    Java Service Name : convertDateToJulianDate
    /**********************************************************************************************
    Convert date values to Julian Date.
    Julian Date is 5 digit number, consisting of a 2 digit year and a 3 digit day-of-year number.
    For example, 24-August-1999 is stored as 99236, since 24-August is the 236th day of the year.
    Pass input Example: date : 29, year: 07 (Ex:last two digit of year), month: 05
    **********************************************************************************************/
    // pipeline
    IDataCursor pipelineCursor = pipeline.getCursor();
    String l_str_date = IDataUtil.getString( pipelineCursor, “date” );
    String l_str_year= IDataUtil.getString( pipelineCursor, “year” ); //Pass only 2 digit of year to me…
    String l_str_month = IDataUtil.getString( pipelineCursor, “month” );
    pipelineCursor.destroy();

    // giving some work to JVM… - Find day of year
    int l_int_date = Integer.parseInt(l_str_date);
    int l_int_year = Integer.parseInt(l_str_year);
    int l_int_month = Integer.parseInt(l_str_month);
    Calendar l_cal_obj = Calendar.getInstance();
    l_cal_obj.set(l_int_year,l_int_month,l_int_date); //year, month, date
    int l_int_dayofyear = l_cal_obj.get(Calendar.DAY_OF_YEAR); // i am a day of year…
    String l_str_julianDate = l_str_year + String.valueOf(l_int_dayofyear); //i am a julianDate…
    String l_str_obj_julian = new String(l_str_julianDate);

    // pipeline - Assign final output to service output…
    IDataCursor pipelineCursor_1 = pipeline.getCursor();
    IDataUtil.put( pipelineCursor_1, “juliandate”, l_str_obj_julian);
    pipelineCursor_1.destroy();





    5. now you can invoke this java services from any flow services and get your expected result… and run with some examples…
    date : 29, year: 07 (Ex:last two digit of year), month: 05-- It will give output like “07180”

    Hope this Helps!

    Thanks!
    ArulChristhuRaj


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


  • 3.  RE: convert a date YYMMDD into Julian format

    Posted Tue May 29, 2007 05:25 PM

    Why, oh why do people always want to use Java? Just a little bit of reading of the wM IS documentation would have revealed that creating a Java service for this was not necessary.

    The date formatting services provided in the pub.date folder clearly support day-of-year. There is no need to write a Java service to simply convert from one date format to another.


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


  • 4.  RE: convert a date YYMMDD into Julian format

    Posted Tue May 29, 2007 11:30 PM

    HI ArulChristhuRaj,

    Thanks a lot, i will try it and let you know.

    Thanks reamon.

    Cheers,
    Sree


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


  • 5.  RE: convert a date YYMMDD into Julian format

    Posted Tue May 29, 2007 11:52 PM

    I would encourage you to consider using the built-in service rather than creating a Java service. There would seem to be no point in reinventing the wheel.


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


  • 6.  RE: convert a date YYMMDD into Julian format

    Posted Wed May 30, 2007 06:42 AM

    Yes. I agree raemon’s word…

    Sree you can use following flow service to get Julian Date.

    1. to find dayofyear use pub.date.dateBuild flow service.
    Input:Pattern= “D”,year= “07”,month=“5”,dayofmonth=“29”,timezone=“IST”
    Output: “149”
    2. to concat prefix of the year with dayofyear use pub.string.concat.

    HTH

    Thanks!
    ArulChristhuRaj


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


  • 7.  RE: convert a date YYMMDD into Julian format

    Posted Wed May 30, 2007 07:25 AM

    Hi Arul,

    Thanks a lot for you valuable suggestions but my requirement is Julian Format of this way.

    I am converting YYMMDD , "070530’ into
    Number of Years since 1900 + Number of Days since the first day of the current year.
    i.e today date is “107150”.
    “070530” into “107150”
    please guide me on this…

    Thanks Raemon’s and Arul

    Thanks,
    Sree


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


  • 8.  RE: convert a date YYMMDD into Julian format

    Posted Wed May 30, 2007 03:03 PM

    SimpleDateFormat sdf = new SimpleDateFormat( “yyyyMMdd” );
    SimpleDateFormat jdeSdf = new SimpleDateFormat( “yyDDD” );
    String locDateString = “”;
    String outDateJDE = “”;
    IDataCursor idcPipeline = pipeline.getCursor();
    if (idcPipeline.first( “inDateYYYYMMDD” )) {
    locDateString = (String)idcPipeline.getValue();
    try {
    Date locDate = sdf.parse( locDateString );
    outDateJDE = “1” + jdeSdf.format( locDate );
    } catch (NullPointerException e ) {}
    catch (ParseException e ) {}
    }
    idcPipeline.insertAfter( “outDateJDE”, outDateJDE );
    idcPipeline.destroy();


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


  • 9.  RE: convert a date YYMMDD into Julian format

    Posted Wed May 30, 2007 04:54 PM

    This date formatting transform can done with an existing service.

    Call pub.date:dateFormat with following inputs:

    inString: 070530 or map in the appropriate variable
    currentPattern: yyMMdd
    newPattern: 1yyDDD

    The literal ‘1’ in the newPattern means that this solution will work only for dates for years 2000-2099. If you need to handle dates before 2000 then a slight change will be needed.

    I encourage everyone to review the wM IS Built-in Service Reference. Often one will find solutions without needing to create a new service at all–a new service was not needed in this case.


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


  • 10.  RE: convert a date YYMMDD into Julian format

    Posted Fri June 01, 2007 12:15 AM

    Hi Michel/reamon

    Thanks a lot, I will try this and let you know.

    Thanks,
    Sreekanth


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