Here you can find the source of getThisMonth()
public static List<String> getThisMonth()
//package com.java2s; /**/* w w w . j a v a 2s . c o m*/ * Copyright (c)2010-2011 Enterprise Website Content Management System(EWCMS), All rights reserved. * EWCMS PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * http://www.ewcms.com */ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; public class Main { private static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd"; public static List<String> getThisMonth() { return getThisMonth(DEFAULT_DATE_FORMAT); } public static List<String> getThisMonth(String format) { List<String> list = new ArrayList<String>(); try { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); Date firstDate = calendar.getTime(); SimpleDateFormat simple = new SimpleDateFormat(format); Date current = new Date(Calendar.getInstance().getTime().getTime()); Long mid = current.getTime() - firstDate.getTime() + 1; int day = (int) (mid / (1000 * 60 * 60 * 24)); calendar.setTime(firstDate); list.add(simple.format(firstDate.getTime())); for (int i = 0; i < day; i++) { calendar.add(Calendar.DATE, 1); list.add(simple.format(calendar.getTime())); } } catch (Exception e) { } return list; } }