Get Last day of the month

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

Review the java.util.Calendar class.

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

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

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

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

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();