Here you can find the source of setMinute(Date date, int minute)
Set minute of date object.License
Open Source LicenseParameter
Parameter | Description |
---|---|
date | target date |
minute | variable number |
public static Date setMinute(Date date, int minute)
//package com.java2s; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /**/* w w w . ja va2 s . co m*/ * <pre> * Set minute of date object. * * DateUtils.setMinute(1970-01-01 17:00:00, 17) = 1970-01-01 17:17:00 * </pre> * * @param date target date * @param minute variable number * @return Date */ public static Date setMinute(Date date, int minute) { if (date == null) { return null; } Calendar c = getCalendar(date); c.set(Calendar.MINUTE, minute); return c.getTime(); } /** * get GregorianCalendar. * * @return Calendar,GregorianCalendar. */ public static Calendar getCalendar() { return new GregorianCalendar(); } /** * get GregorianCalendar with given date. * * @param date Date. * @return Calendar, GregorianCalendar. */ public static Calendar getCalendar(Date date) { Calendar calendar = getCalendar(); calendar.setTime(date); return calendar; } }