Java Date to Time getTime(Date trialTime)

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

Description

get Time

License

Open Source License

Declaration

public static String getTime(Date trialTime) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

import java.util.Date;

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

    public static String getTime() {
        return dateToString(now(), DF_HMS);
    }//ww w  . ja v  a  2s.  c om

    public static String getTime(Date trialTime) {
        return dateToString(trialTime, DF_HMS);
    }

    public static String dateToString(Date date, String format) {
        if (date == null) {
            return "";
        }
        synchronized (date) {
            SimpleDateFormat df = new SimpleDateFormat(format);
            return df.format(date);
        }
    }

    public static String dateToString(Date date) {
        return dateToString(date, DF_YMD);
    }

    public static Date now() {
        return new Date();
    }
}

Related

  1. getTime(Date date, boolean isEnd)
  2. getTime(Date date, String pattern, Locale locale)
  3. getTime(Date dateParam)
  4. getTime(Date executionTime)
  5. getTime(Date timestamp)
  6. getTime(final Date date, final int day)
  7. getTime(final Date time)
  8. getTime(java.util.Date date)
  9. getTime(java.util.Date date)