Java Day of Month getDayOfMonth(Date date)

Here you can find the source of getDayOfMonth(Date date)

Description

get Day Of Month

License

Open Source License

Declaration

public static int getDayOfMonth(Date date) 

Method Source Code

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

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

public class Main {
    public static int getDayOfMonth(Date date) {
        Calendar calendar = getCalendarFromDate(date);
        return calendar.get(Calendar.DAY_OF_MONTH);
    }//from   www .j a  v  a  2s  .  c om

    /**
     * get calendar from date
     *
     * @param date the passing date
     * @return the calendar instance
     */
    public static Calendar getCalendarFromDate(Date date) {
        Calendar calendar = getDefaultCalendar();
        calendar.setTime(date);
        return calendar;
    }

    /**
     * get the default calendar
     *
     * @return the calendar instance
     */
    public static Calendar getDefaultCalendar() {
        Calendar calendar = Calendar.getInstance();
        calendar.setFirstDayOfWeek(Calendar.MONDAY);
        return calendar;
    }
}

Related

  1. adjustToDayOfMonth(Date dt, int day)
  2. dayOfMonth(Date date)
  3. dayOfMonthOf(Date date)
  4. getDayofMonth(Date date)
  5. getDayOfMonth(Date date)
  6. getDayOfMonth(Date date)
  7. getDayOfMonth(Date date)
  8. getDayOfMonth(Date dt)
  9. getDayOfMonth(final Date date)