Here you can find the source of formatSmartDate(Date date)
Parameter | Description |
---|---|
date | The date to be formated. |
public static String formatSmartDate(Date date)
//package com.java2s; //License from project: LGPL import java.text.*; import java.util.Date; import java.util.Locale; public class Main { /**/*from w w w . j a v a2 s . c o m*/ * Format a date as returned for producing a portable player readable date. * (9 characters). * * @param date * The date to be formated. * * @return String The formatted date, "yy-MM-dd" * */ public static String formatSmartDate(Date date) { DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.US); try { SimpleDateFormat simpleFormatter = (SimpleDateFormat) formatter; simpleFormatter.applyPattern("yy-MM-dd"); String result = simpleFormatter.format(date); return result; } catch (Exception e) { // Simple formatter not supported. } return ""; } }