Java examples for java.util:Month
get date of This Month
//package com.java2s; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static Date[] getThisMonth() { GregorianCalendar calendar = new GregorianCalendar(); calendar.set(GregorianCalendar.HOUR_OF_DAY, 0); calendar.set(GregorianCalendar.MINUTE, 0); calendar.set(GregorianCalendar.SECOND, 0); calendar.set(GregorianCalendar.DATE, 1); Date begin = calendar.getTime(); calendar.add(GregorianCalendar.MONTH, 1); calendar.add(GregorianCalendar.DATE, -1); calendar.set(GregorianCalendar.HOUR_OF_DAY, 23); calendar.set(GregorianCalendar.MINUTE, 59); calendar.set(GregorianCalendar.SECOND, 59); Date end = calendar.getTime(); return new Date[] { begin, end }; }/*from w w w . j a v a 2 s.com*/ }