Java Date Offset getOffsetDateToDate(Date pDate, int offset)

Here you can find the source of getOffsetDateToDate(Date pDate, int offset)

Description

get Offset Date To Date

License

Open Source License

Declaration

public static Date getOffsetDateToDate(Date pDate, int offset) throws Exception 

Method Source Code

//package com.java2s;
//License from project: GNU General Public License 

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {

    public static Date getOffsetDateToDate(Date pDate, int offset) throws Exception {
        Calendar c = Calendar.getInstance();
        Date ret = null;//  ww w. jav  a2 s  .co m

        try {
            c.setTime(pDate);
            c.add(6, offset);
            ret = c.getTime();
        } catch (Exception e) {
        }
        return ret;
    }

    public static Date getOffsetDateToDate(String strDate, int offset) throws Exception {

        SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
        Date date = fmt.parse(strDate);

        return getOffsetDateToDate(date, offset);
    }
}

Related

  1. getOffsetDateInFormat(int offsetDay, String pattern)
  2. getOffsetDate(Date protoDate, int dayOffset)
  3. getOffsetDate(String startTime, int field, int offset)
  4. getOffsetMins(String strDate, String strDate2)
  5. getOffsetDate(String strDate, int offset, String pFormat)
  6. getOffsetMonth(Date pDate, int offset, String pFormat)
  7. getOffsetDate(String strDate, int offset, String pFormat)