Android Date Set setMinute(Date date, int minutes)

Here you can find the source of setMinute(Date date, int minutes)

Description

set Minute

License

Open Source License

Declaration

public static Date setMinute(Date date, int minutes) 

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 Date setMinute(Date date, int minutes) {
        return setTime(date, -1, minutes, -1, -1);
    }/*from www  . j a v  a  2s .com*/

    public static Date setTime(Date date, int hours, int minutes) {
        return setTime(date, hours, minutes, -1, -1);
    }

    public static Date setTime(Date date, int hours, int minutes,
            int seconds) {
        return setTime(date, hours, minutes, seconds, -1);
    }

    public static Date setTime(Date date, int hour, int minute, int second,
            int millisecond) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.HOUR_OF_DAY,
                hour >= 0 ? hour : c.get(Calendar.HOUR_OF_DAY));
        c.set(Calendar.MINUTE,
                minute >= 0 ? minute : c.get(Calendar.MINUTE));
        c.set(Calendar.SECOND,
                second >= 0 ? second : c.get(Calendar.SECOND));
        c.set(Calendar.MILLISECOND,
                millisecond >= 0 ? millisecond : c
                        .get(Calendar.MILLISECOND));
        return c.getTime();
    }
}

Related

  1. set(Date date, int calendarField, int amount)
  2. setDays(Date date, int amount)
  3. setHour(Date date, int hours)
  4. setHours(Date date, int amount)
  5. setMilliseconds(Date date, int amount)
  6. setMinutes(Date date, int amount)
  7. setMonths(Date date, int amount)
  8. setSeconds(Date date, int amount)
  9. setTime(Date date, int hour, int minute, int second, int millisecond)