Java SQL Date getNextDayStr(String curday)

Here you can find the source of getNextDayStr(String curday)

Description

get Next Day Str

License

Apache License

Declaration

public static String getNextDayStr(String curday) 

Method Source Code


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

import java.text.SimpleDateFormat;

import java.util.*;

public class Main {
    static public SimpleDateFormat MMddYYYY_HHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    static public SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyy-MM-dd");

    public static String getNextDayStr(String curday) {
        java.util.Date date = str2date(curday);
        return date2str(new Date(date.getTime() + 24 * 3600 * 1000));
    }//from ww w.  ja  v  a2 s .c o m

    public static Date str2date(String str) {
        Date result = null;
        try {
            Date udate = yyyyMMdd.parse(str);
            result = new Date(udate.getTime());
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static String date2str(java.util.Date date) {
        if (date == null)
            return "";
        try {
            return MMddYYYY_HHmmss.format(date);
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    static public String date2str(java.sql.Date date) {
        if (date == null)
            return "";
        try {
            return yyyyMMdd.format(date);
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }

    }

    public static String getTime(String parrten) {
        String timestr;
        if (parrten == null || parrten.equals("")) {
            parrten = "yyyyMMddHHmmss";
        }
        java.text.SimpleDateFormat sdf = new SimpleDateFormat(parrten);
        java.util.Date cday = new java.util.Date();
        timestr = sdf.format(cday);
        return timestr;
    }
}

Related

  1. getInsertarEntrada()
  2. getIntervalDays(String sd, String ed)
  3. getLastDay()
  4. getMonthInt(String month)
  5. getNextDayStr(String curday)
  6. getNow()
  7. getNow()
  8. getNowHour()
  9. getProtobufClass(Object value, Class protobufClass)