Java Date to Time getTime(Date date)

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

Description

get Time

License

Apache License

Declaration

public static String getTime(Date date) 

Method Source Code

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

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static String getTime(Date date) {
        return format(date, "HH:mm:ss");
    }//from   w w  w  .  j  a  va2s.c o  m

    public static String format(Date date, String format) {
        String result = "";
        try {
            if (date != null) {
                DateFormat dateFormat = new SimpleDateFormat(format);
                result = dateFormat.format(date);
            }
        } catch (Exception localException) {
        }
        return result;
    }

    public static String format(Date date) {
        return format(date, "yyyy-MM-dd");
    }
}

Related

  1. getTime(Date date)
  2. getTime(Date date)
  3. getTime(Date date)
  4. getTime(Date date)
  5. getTime(Date date)
  6. getTime(Date date)
  7. getTime(Date date, boolean isEnd)
  8. getTime(Date date, String pattern, Locale locale)
  9. getTime(Date dateParam)