Android examples for java.util:Date Format
format Date to string in yyyy-MM-dd format and check null value
import android.util.Log; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; public class Main{ /** The default formatter for full date */ private static final DateFormat FULL_DATE_FORMATTER = new SimpleDateFormat( "yyyy-MM-dd"); /**/*from w w w . ja v a 2 s.com*/ * Formats the given date using the default full date formatter. */ public static String formatFullDate(Date date) { String dateString = ""; if (date != null) { dateString = FULL_DATE_FORMATTER.format(date); } return dateString; } }