Android Date Format getFormatDateTommorrow(String sourceDate, String format)

Here you can find the source of getFormatDateTommorrow(String sourceDate, String format)

Description

get Format Date Tommorrow

Declaration

public static String getFormatDateTommorrow(String sourceDate,
            String format) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static String getFormatDateTommorrow(String sourceDate,
            String format) {/*from  w w w .  ja va  2 s.  c o m*/
        return getFormatDateAdd(getDateFromString(sourceDate, format), 1,
                format);
    }

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

    public static Date getDateFromString(String dateStr, String pattern) {
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        Date resDate = null;
        try {
            resDate = sdf.parse(dateStr);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return resDate;
    }

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

Related

  1. getFormatDateAdd(Date date, int amount, String format)
  2. getFormatDateAdd(Date date, int amount, String format)
  3. getFormatDateTime(Date date, String format)
  4. getFormatDateTime(Date date, String format)
  5. getFormatDateTommorrow(String sourceDate, String format)
  6. getFormatShortTime(Date date)
  7. getFormatTime(Date date)
  8. getFormatTomorrow(String format)
  9. getFormatYestoday(String format)