get Current Date by format - Android java.util

Android examples for java.util:Date

Description

get Current Date by format

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 getCurrentDate(String format) {
        return new SimpleDateFormat(format, Locale.CHINA)
                .format(new Date());
    }/*w  w w.ja v a2  s  . c o  m*/

}

Related Tutorials