Java Date to Minute minuteDate(Date date, int num)

Here you can find the source of minuteDate(Date date, int num)

Description

minute Date

License

Open Source License

Declaration

public static Date minuteDate(Date date, int num) 

Method Source Code

//package com.java2s;
/*/*from   w  w  w  . j av a 2s.  c  o m*/
 *  DateUtils.java
 *  
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *  
 *  Author: Winter Lau (javayou@gmail.com)
 *  http://dlog4j.sourceforge.net
 */

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

public class Main {

    public static Date minuteDate(Date date, int num) {
        Calendar now = Calendar.getInstance();
        now.setTime(date);
        int year = now.get(Calendar.YEAR);
        int month = now.get(Calendar.MONTH);
        int day = now.get(Calendar.DAY_OF_MONTH);
        now.set(year, month, day);
        now.add(Calendar.MINUTE, num);
        return now.getTime();
    }
}

Related

  1. getMinutesInDay(Date d)
  2. getMinutesOfHour(Date dt)
  3. minute(Date date)
  4. minute(final Date date)
  5. minuteAdd(Date date, int val)
  6. minuteOf(Date date)