Java String to Time getFormerDate(String dateTime)

Here you can find the source of getFormerDate(String dateTime)

Description

get Former Date

License

Apache License

Declaration

public static String getFormerDate(String dateTime) throws ParseException 

Method Source Code


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

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

public class Main {

    public static String getFormerDate(String dateTime) throws ParseException {

        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        long dif = df.parse(dateTime).getTime() - 86400 * 1000;
        Date date = new Date();
        date.setTime(dif);/*  ww  w.  j  a  va 2s.  co m*/
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

        return sdf.format(date);
    }
}

Related

  1. getCalendarFromDate(final String dateTime)
  2. getDlayDateTime(String playDate, String playTime)
  3. getEndTime(String flag, int value)
  4. getExecutionDateTime(String input)
  5. getExpireTime(String timeStr)
  6. getIdByTime(String name)
  7. getMReportTime(String time)
  8. getSignTime(final String stStr)
  9. getStringWithTime(String str)