Java Utililty Methods Time Now

List of utility methods to do Time Now

Description

The list of methods to do Time Now are organized into topic(s).

Method

StringgetThaiCurrentTime()
get Thai Current Time
java.text.SimpleDateFormat thaiCurrentTime = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss",
        new java.util.Locale("th", "TH"));
System.out.println(thaiCurrentTime.format(new java.util.Date()));
return thaiCurrentTime.format(new java.util.Date());
StringgetTimeFromCurrent(long l)
get Time From Current
if (l == 0)
    return "";
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(l));
StringgetTimeString()
Helper method that returns the date and time in a format that can be used to create filenames.
return new SimpleDateFormat("MM-dd-YY_k-mm").format(Calendar.getInstance().getTime());
StringgetTimeString()
Get the current time in the default format.
Date date = new Date();
return timeFormat.format(date);
StringgetTimeString()
get Time String
DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Date today = Calendar.getInstance().getTime();
return df.format(today);
StringgetTimeString()
get Time String
return new SimpleDateFormat("HH:mm:ss").format(nowDate());
StringprintTime()
print Time
return new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime());
voidprintTime()
print Time
System.out.println(getTime());
StringprintTime(Date date)
print Time
if (date == null)
    return null;
DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
DateFormat tzFormatter = new SimpleDateFormat("Z");
String timezone = tzFormatter.format(date);
return formatter.format(date) + timezone.substring(0, 3) + ":" + timezone.substring(3);
StringreadCurrentTime()
read Current Time
Date dateNow = Calendar.getInstance(new SimpleTimeZone(9 * 60 * 60 * 1000, "KST")).getTime();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmssSSS", Locale.getDefault());
return formatter.format(dateNow);