Return date in month and day of month format in device locale - Android java.util

Android examples for java.util:Month

Description

Return date in month and day of month format in device locale

Demo Code


//package com.java2s;
import android.support.annotation.NonNull;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class Main {
    private static final SimpleDateFormat MONTH_DAY_IN_NUMBER_FORMAT = new SimpleDateFormat(
            "d/M", Locale.getDefault());

    /**/*from w w  w  . ja v  a 2  s.  c  om*/
     * Return date in month and day of month format in device locale
     *
     * @param date
     * @return formated date eg : "1/5" "1/12" etc.
     */
    public static String formatDateInMonthDayNumberRepresentation(
            @NonNull final Date date) {
        final String parsedDate = MONTH_DAY_IN_NUMBER_FORMAT.format(date);
        return parsedDate;
    }
}

Related Tutorials