Java Hour Format formateEndTimeString(String time)

Here you can find the source of formateEndTimeString(String time)

Description

formate End Time String

License

Open Source License

Declaration

public static String formateEndTimeString(String time) 

Method Source Code


//package com.java2s;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static final String BASE_PATTERN = "yyyy-MM-dd HH:mm:ss";

    public static String formateEndTimeString(String time) {
        return formateTimeString(time, "end");
    }//from   w  w  w. j a  v  a 2s . c om

    public static String formateTimeString(String time, String type) {
        if (time == null || time.length() < 10) {
            return "";
        }
        if (time.length() < 14) {
            if (type.toLowerCase().equals("end")) {
                time += " 23:59:59";
            } else {
                time += " 00:00:00";
            }
        }
        SimpleDateFormat formatter = new SimpleDateFormat(BASE_PATTERN);
        Date myDate = null;
        try {
            myDate = formatter.parse(time);
            String timeStr = formatter.format(myDate);
            return timeStr;
        } catch (ParseException e) {
            e.printStackTrace();
            return "";
        }
    }

    public static String formateTimeString(String time) {
        return formateTimeString(time, "start");
    }
}

Related

  1. formateDataC(Date date)
  2. formateDate(Date date)
  3. formateDate(Date date, String format)
  4. forMateDate(String dateStr)
  5. formateDaTime(Date date)
  6. formatEndTime(String datePre)
  7. formatFF(String date)
  8. formatFileDate(Date from)
  9. formatFilesystemOrder(Date date)