Java examples for java.util:Month
get End Of Month in Milliseconds
//package com.java2s; import java.util.Calendar; public class Main { public static void main(String[] argv) throws Exception { int year = 2; int month = 2; System.out.println(getEndOfMonthMs(year, month)); }//from ww w. ja v a 2s . co m public static long getEndOfMonthMs(int year, int month) { final Calendar date = Calendar.getInstance(); date.set(Calendar.YEAR, year); date.set(Calendar.MONTH, month); date.set(Calendar.DAY_OF_MONTH, date.getActualMaximum(Calendar.DAY_OF_MONTH)); date.set(Calendar.HOUR_OF_DAY, date.getActualMaximum(Calendar.HOUR_OF_DAY)); date.set(Calendar.MINUTE, date.getActualMaximum(Calendar.MINUTE)); date.set(Calendar.SECOND, date.getActualMaximum(Calendar.SECOND)); date.set(Calendar.MILLISECOND, date.getActualMaximum(Calendar.MILLISECOND)); return date.getTimeInMillis(); } }