Format Date to String by Locale - Android java.util

Android examples for java.util:Date Format

Description

Format Date to String by Locale

Demo Code

import android.text.TextUtils;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;

public class Main{


    public static String convertDate2Str(Date date) {
        return new SimpleDateFormat(dateFormatYMDHMS, Locale.CHINA)
                .format(date);//from w  w w  .  j av a2 s  .c  om
    }

    public static String convertDate2Str(Date date, String format) {
        return new SimpleDateFormat(format, Locale.CHINA).format(date);
    }

}

Related Tutorials