Java Day of getDeltaDay(String day, int delta)

Here you can find the source of getDeltaDay(String day, int delta)

Description

get Delta Day

License

Apache License

Declaration

public static String getDeltaDay(String day, int delta) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Calendar;

import java.util.GregorianCalendar;

public class Main {

    public static String getDeltaDay(String day, int delta) {
        GregorianCalendar rightNow = new GregorianCalendar(Integer.parseInt(day.substring(0, 4)),
                Integer.parseInt(day.substring(4, 6)) - 1, Integer.parseInt(day.substring(6, 8)));
        rightNow.add(Calendar.DAY_OF_YEAR, delta);
        return getDefaultDateFormat().format(rightNow.getTime());
    }/*from w  ww  . j  a v a2s  .  c  om*/

    public static int parseInt(String s) {
        return Integer.parseInt(isZero(s));
    }

    public static SimpleDateFormat getDefaultDateFormat() {
        return new SimpleDateFormat("yyyyMMdd");
    }

    public static String isZero(String o) {
        return (o == null || o.toString().trim().equals("")) ? "0" : o;
    }
}

Related

  1. getConfirmDateTimeOfDay(Date currentDate)
  2. getCurDayZero()
  3. getDataFile(int tableId, Date day)
  4. getDataTimeForwordDay(Date date, int dayNum)
  5. getDefaultOffsetDays(String strDate)
  6. getDeltaDays(String date)
  7. getDeltaNow(int deltaDays)
  8. getDisplayDate(final Date date, final int offsetDays)
  9. getEndDayofMouth(String date, String inPattern, String outPattern)