Java Date to Time getTimeMax(Date date)

Here you can find the source of getTimeMax(Date date)

Description

get Time Max

License

Apache License

Declaration

public static Date getTimeMax(Date date) 

Method Source Code

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

import java.text.ParsePosition;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
    public static final String DATE_FORMAT_1 = "yyyy-MM-dd HH:mm:ss";

    public static Date getTimeMax(Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String da = sdf.format(date);
        da = da + " 23:59:59";
        Date d = getStrToDate(DATE_FORMAT_1, da);
        return d;
    }//from   w w w  .j  a  v a2 s  .  c  om

    public static Date getTimeMax() {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String da = sdf.format(date);
        da = da + " 23:59:59";
        Date d = getStrToDate(DATE_FORMAT_1, da);
        return d;
    }

    public static synchronized Date getStrToDate(String format, String str) {
        simpleDateFormat.applyPattern(format);
        ParsePosition parseposition = new ParsePosition(0);
        return simpleDateFormat.parse(str, parseposition);
    }
}

Related

  1. getTimeInterval(Date fromDate)
  2. getTimeIntervalMins(Date firstDate, Date lastDate)
  3. getTimeLocalWithoutDst(java.util.Date d)
  4. getTimeLocalWithoutDst(java.util.Date d)
  5. getTimeMargin(String dateTime)
  6. getTimeOfDate(Date date)
  7. getTimeOnly(Date date)
  8. getTimeOnly(Date date)
  9. getTimeOnly(final Date oDate)