Android Date String to Date Convert getDateTomorrow(String date)

Here you can find the source of getDateTomorrow(String date)

Description

get Date Tomorrow

License

Apache License

Declaration

public static String getDateTomorrow(String date) 

Method Source Code

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

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

public class Main {
    public static String getDateTomorrow(String date) {

        Date tempDate = null;//ww w .  jav  a  2 s. co  m
        if (date.indexOf("/") > 0)
            tempDate = getDateObj(date, "[/]");
        if (date.indexOf("-") > 0)
            tempDate = getDateObj(date, "[-]");
        tempDate = getDateAdd(tempDate, 1);
        return getFormatDateTime(tempDate, "yyyy/MM/dd");
    }

    public static Date getDateObj(int year, int month, int day) {
        Calendar c = new GregorianCalendar();
        c.set(year, month - 1, day);
        return c.getTime();
    }

    public static Date getDateObj(String argsDate, String split) {
        String[] temp = argsDate.split(split);
        int year = new Integer(temp[0]).intValue();
        int month = new Integer(temp[1]).intValue();
        int day = new Integer(temp[2]).intValue();
        return getDateObj(year, month, day);
    }

    public static Date getDateObj() {
        Calendar c = new GregorianCalendar();
        return c.getTime();
    }

    public static Date getDateAdd(Date date, int amount) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(date);
        cal.add(GregorianCalendar.DATE, amount);
        return cal.getTime();
    }

    public static String getFormatDateTime(Date date, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }
}

Related

  1. getDate(String date)
  2. getDateFromString(String dateStr, String pattern)
  3. getDateFromString(String string)
  4. getDateObj(String argsDate, String split)
  5. getDateOffset(String date, int offset)
  6. convertStandardDateTime(String time)
  7. removeTimeZone(String data)
  8. parseFileName(String timeStr)
  9. formatDate(String date)