Java examples for java.util:Month
get Month L Last Day
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static void main(String[] argv) throws Exception { String date = "java2s.com"; System.out.println(getMonthLLastDay(date)); }/*from w ww . j av a 2s.co m*/ private static SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); public static String getMonthLLastDay(String date) throws Exception { Date d = sf.parse(date); Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) + 1); cal.set(Calendar.DAY_OF_MONTH, 0); return sf.format(cal.getTime()); } }