Java Now getTimeNow(Date theTime)

Here you can find the source of getTimeNow(Date theTime)

Description

This method returns the current date time in the format: MM/dd/yyyy HH:MM a

License

Apache License

Parameter

Parameter Description
theTime the current time

Return

the current date/time

Declaration

public static String getTimeNow(Date theTime) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static String timePattern = "HH:mm";

    /**/*from   w  ww  . j  ava2  s.c  om*/
     * This method returns the current date time in the format: MM/dd/yyyy HH:MM
     * a
     * 
     * @param theTime
     *            the current time
     * @return the current date/time
     */
    public static String getTimeNow(Date theTime) {
        return getDateTime(timePattern, theTime);
    }

    /**
     * This method generates a string representation of a date's date/time in
     * the format you specify on input
     * 
     * @param aMask
     *            the date pattern the string is in
     * @param aDate
     *            a date object
     * @return a formatted string representation of the date
     * 
     * @see java.text.SimpleDateFormat
     */
    public static final String getDateTime(String aMask, Date aDate) {
        SimpleDateFormat df = null;
        String returnValue = "";

        df = new SimpleDateFormat(aMask);
        returnValue = df.format(aDate);

        return (returnValue);
    }
}

Related

  1. getInviteCodeByNowDate()
  2. getShortNowTime()
  3. getStringNowTime()
  4. getStringOfNowDate(String fFormatStr)
  5. getTimeNow()
  6. getTimeNowAsString(String pattern)
  7. getTimeSubFromNowTime(String time)
  8. getValidDate(String unknownDate)
  9. isNowInInterval(String start, String end)