Java Date Calculate calculateByDate(Date d, int amount)

Here you can find the source of calculateByDate(Date d, int amount)

Description

calculate By Date

License

Apache License

Declaration

public static Date calculateByDate(Date d, int amount) 

Method Source Code

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

import java.util.Calendar;

import java.util.Date;
import java.util.GregorianCalendar;

public class Main {

    public static Date calculateByDate(Date d, int amount) {
        return calculate(d, Calendar.DATE, amount);
    }/*from  w  w w  . ja va 2 s  . c  o  m*/

    private static Date calculate(Date d, int field, int amount) {
        if (d == null)
            return null;
        GregorianCalendar g = new GregorianCalendar();
        g.setGregorianChange(d);
        g.add(field, amount);
        return g.getTime();
    }
}

Related

  1. calculaDataTermino(Date dataInicio, int prazo)
  2. calculaIdadeEmAnos(Date dDataNasc, Date dataRef)
  3. calculaIdadeEmMeses(Date dDataNasc)
  4. calculaIdadeMesAno(Date dDataNasc, String type)
  5. calculate(Date d, int field, int amount)
  6. calculateDate(Date date, int field, int value)
  7. calculateDays(Date startDate, Date endDate)
  8. calculateDurationEndInSec(Date start, int durationInSeconds)
  9. calculateEndDate(Date startDate, int duration)