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);/*www  .  j a v a2s . c o m*/
        return format.format(date);
    }

}

Related Tutorials