Android Date Set offsetDate(Date date, int field, int offset)

Here you can find the source of offsetDate(Date date, int field, int offset)

Description

offset Date

License

Open Source License

Declaration

public static Date offsetDate(Date date, int field, int offset) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static Date offsetDate(Date date, int field, int offset) {
        Calendar calendar = convert(date);
        calendar.add(field, offset);//  w  ww  .j  ava2s. c  o  m
        return calendar.getTime();
    }

    private static Calendar convert(Date date) {
        Calendar calendar = new GregorianCalendar();
        calendar.setTime(date);
        return calendar;
    }
}

Related

  1. setTime(Date date, int hours, int minutes, int seconds)
  2. setYears(Date date, int amount)
  3. shortDate(Date date)
  4. time(Date date)
  5. toDateTime(Date date, Date time)
  6. changeDate(String argDate)
  7. firstTimeOfDate(Date date)
  8. resetTime(Date date)
  9. removeTime(Date date)