Format date in HH format - Android java.util

Android examples for java.util:Date Format

Description

Format date in HH format

Demo Code

import android.annotation.SuppressLint;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class Main{

    public static String date2HH(Date date) {
        return new SimpleDateFormat("HH").format(date);
    }//from   ww  w  .j  a v a 2s. c  om

}

Related Tutorials