Java Month Calculate isFirstOfMonth(long date)

Here you can find the source of isFirstOfMonth(long date)

Description

is First Of Month

License

Open Source License

Declaration

public static boolean isFirstOfMonth(long date) 

Method Source Code

//package com.java2s;
/*//www .  j av a 2s.  c om
 * $Id: DateUtils.java,v 1.1 2004/08/12 00:24:33 dmouse Exp $
 *
 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

import java.util.*;

public class Main {
    private static Calendar CALENDAR = Calendar.getInstance();

    public static boolean isFirstOfMonth(long date) {
        boolean ret = false;
        Calendar calendar = CALENDAR;
        synchronized (calendar) {
            calendar.setTimeInMillis(date);
            int currentMonth = calendar.get(Calendar.MONTH);
            // Check yesterday
            calendar.add(Calendar.DATE, -1);
            int yesterdayMonth = calendar.get(Calendar.MONTH);
            ret = (currentMonth != yesterdayMonth);
        }
        return ret;
    }
}

Related

  1. getStartOfMonth(Calendar scal)
  2. getThisMonthEnd()
  3. getThisMonthStart()
  4. incrementMonth(long date, int increment)
  5. intToCalendarMonth(int month)
  6. isMonthEnd(Date date)
  7. isSameMonth(final Calendar c1, final Calendar c2)
  8. monthsBetween(String pFormerStr, String pLatterStr)
  9. nextMonth(Date date, int months)