Java Date Format Guess getDateFormat(Date date, String format)

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

Description

get Date Format

License

Apache License

Declaration

public static String getDateFormat(Date date, String format) 

Method Source Code

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

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    /**/* w w w  .  j  a  va 2 s.c  o m*/
     * @author Administrator
     *   format = "yyyy-MM-dd"
     *   format = "yyyy-MM-dd HH:mm:ss"
     */
    public static String getDateFormat(Date date, String format) {
        String strDateTime = "";
        DateFormat df = new SimpleDateFormat(format);
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        strDateTime = df.format(date);
        return strDateTime;
    }
}

Related

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