Java Date Set setStartTime(Date date)

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

Description

set Start Time

License

Apache License

Declaration

public static Date setStartTime(Date date) 

Method Source Code

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

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

public class Main {
    public static Date setStartTime(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);/*from w  ww  .  j  av a 2  s .  c o m*/
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return cal.getTime();
    }

    public static Date setTime(Date date, int hour, int mins, int secs) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.set(Calendar.HOUR_OF_DAY, hour);
        cal.set(Calendar.MINUTE, mins);
        cal.set(Calendar.SECOND, secs);
        cal.set(Calendar.MILLISECOND, 0);
        return cal.getTime();
    }
}

Related

  1. setMinSeconds(Date date)
  2. setMinute(Date date, int minute)
  3. setMinutes(Date date, int amount)
  4. setStartDateIfNull(java.util.Date start)
  5. setStartDay(Date date)
  6. setTime(Date date, int hourOfDay, int minute, int second)
  7. setTime(Date date, int hours, int minutes, int seconds, int millis)
  8. setTime(Date date, String timeString)
  9. setTime(final Date date, final int hourOfDay, final int minute, final int second)