Thx for your soln. I have managed the same using following code in my java service.
GregorianCalendar prev_month_end_date=new GregorianCalendar();
prev_month_end_date.add(GregorianCalendar.MONTH,-1);
prev_month_end_date.set(GregorianCalendar.DAY_OF_MONTH,prev_month_end_date.getActualMinimum(GregorianCalendar.DAY_OF_MONTH));
Date dtFrom = new java.sql.Date((prev_month_end_date.getTime()).getTime());
SimpleDateFormat sdf = new SimpleDateFormat(datePattern);
String fromdate=sdf.format(dtFrom);
System.out.println("The from date is"+fromdate);