Java Date to Time getTime(Date executionTime)

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

Description

get Time

License

Apache License

Declaration

public static String getTime(Date executionTime) 

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 executionTime) {
        SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
        return formatter.format(executionTime);
    }// w  w w  . jav a 2 s  .  co  m

    public static Date getTime(String timeInString) {

        DateFormat dateFormat = new SimpleDateFormat("hh:mm:ss");
        Date date = null;

        try {

            date = dateFormat.parse(timeInString);

            // System.out.println("Date and Time: " + date);

        } catch (Exception e) {
            e.printStackTrace();
        }

        return date;

    }
}

Related

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