Android examples for java.util:Date Format
get Simple Date Format YMD
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Locale; import java.util.TimeZone; import android.text.TextUtils; public class Main { private static SimpleDateFormat sdf; private static Calendar calendar; public static String getSimpleDateFormatYMD(String time) { String mTime = ""; mTime = getNewSimpleDateFormat("yyyyMMdd", time); return mTime; }//w w w .j a v a 2 s . co m public static String getNewSimpleDateFormat(String pattern, String time) { String mTime = ""; if (TextUtils.isEmpty(pattern) || TextUtils.isEmpty(time)) return mTime; sdf = new SimpleDateFormat(pattern, Locale.KOREA); sdf.setTimeZone(TimeZone.getTimeZone("Asia/Seoul")); calendar = Calendar.getInstance(); calendar.setTimeZone(sdf.getTimeZone()); calendar.setTimeInMillis(Long.parseLong(time) * 1000L); mTime = sdf.format(calendar.getTime()); return mTime; } }