Back to project page Common-Library.
The source code is released under:
Apache License
If you think the Android project Common-Library listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.morgan.library.utils; // w w w .j a v a 2 s.c o m import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; /** * ?????????????????????? * * @author Morgan.Ji * */ public class DateUtils { public static final String DATE_ONLY_FORMAT = "yyyy-MM-dd"; public static final String COMPLETE_DATE_FORMAT = "yyyy-MM-dd hh:mm:ss"; /** * ??format??date?????format?????yyyy-MM-dd hh:mm:ss? * * @param date * @return */ public static String dateToString(Date date, String format) { String timeString = null; if (date == null) { return ""; } try { DateFormat formatDate = new SimpleDateFormat(format, Locale.CHINESE); timeString = formatDate.format(date); } catch (Exception e) { e.printStackTrace(); } return timeString; } }