Java Date to Time getTimeString(java.util.Date date)

Here you can find the source of getTimeString(java.util.Date date)

Description

get Time String

License

Apache License

Parameter

Parameter Description
date a parameter

Declaration

public static String getTimeString(java.util.Date date) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**/* w  ww. j a va2s  .c  om*/
     * @param date
     * @return
     */
    public static String getTimeString(java.util.Date date) {
        if (date == null)
            return "";
        SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
        String NDate = formatter.format(date);
        return NDate;
    }

    public static String getTimeString(java.util.Date date, int ss) {
        if (date == null)
            return "";

        SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
        String NDate = formatter.format(date.getTime() + ss * 60000);
        return NDate;
    }

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

    public static String format(Date date, String pattern) {
        return new SimpleDateFormat(pattern).format(date);
    }

    public static long getTime() {

        return (new java.util.Date()).getTime();
    }
}

Related

  1. getTimestampl(Date time1, Date time2)
  2. getTimeStr(Date date, char delimiter)
  3. getTimeString(Date d)
  4. getTimeString(Date date)
  5. getTimeString(Date self)
  6. getTimeText(Date date)
  7. getXSDDateTime()
  8. getXsdDateTime(Date time)
  9. getXsdDateTime(final Date d)