Archive

Posts Tagged ‘format’

Get date time in custom format


Basically, I use [Date] class to get current time and use [SimpleDateFormat] to format my own output.

Just a sample format:

private String getDateTime() {
    // get date time in custom format
    SimpleDateFormat sdf = new SimpleDateFormat("[yyyy/MM/dd - HH:mm:ss]");
    return sdf.format(new Date(appInfo.firstInstallTime));
}

Cheers,
Pete Houston

Advertisements
Categories: Tricks & Tips Tags: , ,