Java Calendar Minute getFirstMinuteOfDay(Calendar dt)

Here you can find the source of getFirstMinuteOfDay(Calendar dt)

Description

Get Calendar (am 00:00)

License

Apache License

Parameter

Parameter Description
Calendar a parameter

Return

Calendar

Declaration

public static Calendar getFirstMinuteOfDay(Calendar dt) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    /**//from  w  w w.ja  v  a  2s. c o  m
     * 
     * Get Calendar (am 00:00)
     * @param Calendar
     * @return Calendar
     */
    public static Calendar getFirstMinuteOfDay(Calendar dt) {

        if (null == dt) {
            return null;
        }

        Calendar calendar = dt;

        Calendar rtnCalendar = Calendar.getInstance();
        rtnCalendar.clear();
        rtnCalendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
        rtnCalendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH));
        rtnCalendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH));

        return rtnCalendar;
    }

    /**
     * 
     * Get Date (am 00:00)
     * @param Date
     * @return Date
     */
    public static Date getFirstMinuteOfDay(Date dt) {

        if (null == dt) {
            return null;
        }

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(dt);

        Calendar rtnCalendar = Calendar.getInstance();
        rtnCalendar.clear();
        rtnCalendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
        rtnCalendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH));
        rtnCalendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH));

        return rtnCalendar.getTime();
    }
}

Related

  1. calendarTodayOf(int hour, int minute, int second, int millis)
  2. clearHoursMinutesSecondsMillis(Calendar calendar)
  3. getMinute(Calendar cal)
  4. getMinutes(Calendar cal)
  5. getMinutes(Calendar cal1, Calendar cal2)
  6. getMinutes(String expression, Calendar time)