Java Date Format Guess getDateFormat(Date date)

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

Description

Date Format yyyy-MM-dd HH:mm:ss

License

Apache License

Parameter

Parameter Description
date a parameter

Return

yyyy-MM-dd HH:mm:ss

Declaration

public static Date getDateFormat(Date date) 

Method Source Code

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

import java.util.Date;

import java.text.ParseException;
import java.text.SimpleDateFormat;

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

    /**//from   www  .  j a  va 2  s .c om
     * Date Format yyyy-MM-dd HH:mm:ss
     * 
     * @param date
     * @return yyyy-MM-dd HH:mm:ss
     */
    public static Date getDateFormat(Date date) {
        SimpleDateFormat df = new SimpleDateFormat(simple);
        try {
            return df.parse(df.format(date));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
}

Related

  1. determineDateFormat(String dateString)
  2. determineDateFormat(String dateString)
  3. determineDateFormat(String dateString)
  4. getDateFormat(Date date, String format)
  5. getDateFormat(String date)
  6. getDateFormat(String date)
  7. getDateFormat(String date)