Java Time Now getTimeString()

Here you can find the source of getTimeString()

Description

get Time String

License

Apache License

Declaration

public static String getTimeString() 

Method Source Code


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

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

public class Main {
    public static String getTimeString() {
        // Create an instance of SimpleDateFormat used for formatting 
        // the string representation of date (month/day/year)
        DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");

        // Get the date today using Calendar object.
        Date today = Calendar.getInstance().getTime();
        // Using DateFormat format method we can create a string 
        // representation of a date with the defined format.
        return df.format(today);
    }/*w w  w .j  av a2  s .com*/
}

Related

  1. getStrCurrentStrTime()
  2. getThaiCurrentTime()
  3. getTimeFromCurrent(long l)
  4. getTimeString()
  5. getTimeString()
  6. getTimeString()
  7. printTime()
  8. printTime()
  9. printTime(Date date)