Format Date to string in MM-dd a hh:mm format - Android java.util

Android examples for java.util:Date Time

Description

Format Date to string in MM-dd a hh:mm 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 getTime4TimeTitle(Date date) {
        SimpleDateFormat format = new SimpleDateFormat("MM-dd a hh:mm",
                Locale.CHINA);/*from w w  w . ja va 2s .co  m*/
        return format.format(date);
    }

}

Related Tutorials