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
  • 1.  Get Last day of the month

    Posted Wed June 09, 2010 04:15 PM

    Hi There,

    can someone please tell me how to find out the last day of the month. I hope we need to right a java service to achieve this. If so can some please provide me the customized java code.

    Thanks,
    veera


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


  • 2.  RE: Get Last day of the month

    Posted Wed June 09, 2010 07:43 PM

    Review the java.util.Calendar class.

    This site has an example that you can adapt to create a Java service.

    [url]http://www.geekpedia.com/code90_Get-the-Last-Day-of-the-Month.html[/url]


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


  • 3.  RE: Get Last day of the month

    Posted Wed June 09, 2010 08:04 PM

    Hi Veera,

    using below code you can find the last day of the month

    Calendar calendar = Calendar.getInstance();
    calendar.set(year, month, date);
    int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    calendar.set(2004, Calendar.FEBRUARY, 1);
    maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    System.out.println("Max Day: " + maxDay);

    Thanks


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


  • 4.  RE: Get Last day of the month

    Posted Wed June 09, 2010 08:22 PM

    Hi There,

    This is the code i am using , still i am getting errors.

    code :

    // pipeline
    IDataCursor pipelineCursor = pipeline.getCursor();
    String month = IDataUtil.getString( pipelineCursor, “month” );
    String year = IDataUtil.getString( pipelineCursor, “year” );
    pipelineCursor.destroy();
    java.util.Calendar calendar = java.util.Calendar.getInstance();
    calendar.set(year,month,1);
    // pipeline
    IDataCursor pipelineCursor_1 = pipeline.getCursor();
    //int lastday = calendar.getActualMaximum(Calender.DAY_OF_MONTH);
    IDataUtil.put( pipelineCursor_1, “lastDate”, Integer.toString(calendar.getActualMaximum(java.util.Calendar.DAY_OF_MONTH)));
    pipelineCursor_1.destroy();

    ERRORs:-

    C:\webMethods65\IntegrationServer\packages\Rama_Test\code\source\Rama_Test\Utilities.java:51: cannot resolve symbol
    symbol : method set (java.lang.String,java.lang.String,int)
    location: class java.util.Calendar
    calendar.set(year,month,1);
    ^
    1 error

    can someone help me?

    Thanks


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


  • 5.  RE: Get Last day of the month

    Posted Wed June 09, 2010 09:21 PM

    Thanks guys, i achieved it :slight_smile:

    this is the code that worked for me:

    // pipeline
    IDataCursor pipelineCursor = pipeline.getCursor();
    String month = IDataUtil.getString( pipelineCursor, “month” );
    String year = IDataUtil.getString( pipelineCursor, “year” );
    pipelineCursor.destroy();
    java.util.Calendar calendar = java.util.Calendar.getInstance();
    int CurrentMonth = Integer.parseInt(month);
    int CurrentYear = Integer.parseInt(year);
    calendar.set(CurrentYear,CurrentMonth,1);
    // pipeline
    IDataCursor pipelineCursor_1 = pipeline.getCursor();
    IDataUtil.put( pipelineCursor_1, “lastDate”, Integer.toString(calendar.getActualMaximum(java.util.Calendar.DAY_OF_MONTH)));
    pipelineCursor_1.destroy();


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