Format Time in HH:mm:ss format - Android java.util

Android examples for java.util:Date Time

Description

Format Time in HH:mm:ss format

Demo Code

import android.util.Log;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class Main{

    public static String getTimeShort() {
        SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
        Date currentTime = new Date();
        String dateString = formatter.format(currentTime);
        return dateString;
    }/*from   ww w .  j a va  2 s. c  o  m*/

}

Related Tutorials