Java SQL Date isLastDayOfMonth(String theDataStr)

Here you can find the source of isLastDayOfMonth(String theDataStr)

Description

is Last Day Of Month

License

Open Source License

Declaration

public static boolean isLastDayOfMonth(String theDataStr) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    private static final int[] DAY_OF_MONTH = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

    public static boolean isLastDayOfMonth(String theDataStr) {
        Date theDate = java.sql.Date.valueOf(theDataStr);
        Calendar c = new GregorianCalendar();
        c.setTime(theDate);//from  w w w.j  a  v  a  2 s . c  o m
        int nowDay = c.get(Calendar.DAY_OF_MONTH);
        c.set(Calendar.DAY_OF_MONTH, 1);
        c.add(Calendar.MONTH, 1);
        c.add(Calendar.DAY_OF_MONTH, -1);
        int lowDayOfMonth = c.get(Calendar.DAY_OF_MONTH);
        if (nowDay == lowDayOfMonth) {
            return true;
        } else {
            return false;
        }
    }

    public static int get(Date date, int type) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.get(type);
    }
}

Related

  1. getTodayAndTomorrow()
  2. getWeekNumber()
  3. getWeekOfMonth(String year, String month, String day)
  4. getYearLater()
  5. hexToBin(String sHexString)
  6. isSimpleColumnType(Class columnType)
  7. isSimpleType(Object obj)
  8. issue20()
  9. now()