Java Date to Time toTimeString(Date date)

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

Description

to Time String

License

Open Source License

Declaration

public static String toTimeString(Date date) 

Method Source Code

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

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

public class Main {

    public static String toTimeString(Date date) {
        if (date == null) {
            return null;
        }//from  w  ww.  j  ava 2  s .c  o  m
        SimpleDateFormat sdff = new SimpleDateFormat("HH:mm:ss");
        String dateStr = sdff.format(getNowDateTime());
        return dateStr;
    }

    public static Date getNowDateTime() {
        return Calendar.getInstance().getTime();
    }

    public static String getTime(Date dt, String format) {
        SimpleDateFormat st = new SimpleDateFormat(format);
        return st.format(dt);
    }
}

Related

  1. toMT4TimeString(Date date)
  2. toSimpleDateTime(Date date)
  3. toTime(Date... date)
  4. toTimeStr(Date date)
  5. ToTimeStr(Date dt)
  6. toTimeString(Date date)
  7. toTimeString(Date date)
  8. toTimeString(Date dateTime)
  9. toTimeString(Date time)