Java Minute getDateTime(Date d, int hour, int minute, int second, int millisecond)

Here you can find the source of getDateTime(Date d, int hour, int minute, int second, int millisecond)

Description

Returns the passed date, at the specified time

License

Open Source License

Declaration

public static Date getDateTime(Date d, int hour, int minute,
        int second, int millisecond) 

Method Source Code

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

import java.util.*;

public class Main {
    /**/*from w w w . j a v  a2 s .  c o m*/
     * Returns the passed date, at the specified time
     */
    public static Date getDateTime(int year, int mon, int day, int hr,
            int min, int sec, int ms) {
        Calendar c = Calendar.getInstance();
        c.set(Calendar.YEAR, year);
        c.set(Calendar.MONTH, mon - 1);
        c.set(Calendar.DATE, day);
        c.set(Calendar.HOUR_OF_DAY, hr);
        c.set(Calendar.MINUTE, min);
        c.set(Calendar.SECOND, sec);
        c.set(Calendar.MILLISECOND, ms);
        return c.getTime();
    }

    /**
     * Returns the passed date, at midnight
     */
    public static Date getDateTime(int year, int mon, int day) {
        return getDateTime(year, mon, day, 0, 0, 0, 0);
    }

    /**
     * Returns the passed date, at the specified time
     */
    public static Date getDateTime(Date d, int hour, int minute,
            int second, int millisecond) {
        Calendar c = Calendar.getInstance();
        c.setTime(d);
        c.set(Calendar.HOUR_OF_DAY, hour);
        c.set(Calendar.MINUTE, minute);
        c.set(Calendar.SECOND, second);
        c.set(Calendar.MILLISECOND, millisecond);
        return c.getTime();
    }
}

Related

  1. countMinute(Long time)
  2. elapsedMinutes(int beginTimeInMinutes, int endTimeInMinutes)
  3. extractMinutes(String[] parts)
  4. floorTimestamp(Date ts, int windowMinutes)
  5. getDateAfter(Date date, int minute)
  6. isMinute(int num)
  7. isValidMinute(final int min)
  8. isWholeMinute(int seconds)
  9. minute(double serial_number)