/** Format: May 16, 2008 */ public static String formatDefaultUSA(Date date) { String countryCode = "US"; String languageCode = "en"; return convertToLocalized(date, countryCode, languageCode, DateFormat.DEFAULT); } public static String convertToLocalized(Date date, String countryCode, String languageCode, int format) { Locale locale = new Locale(languageCode, countryCode); DateFormat df = DateFormat.getDateInstance(format, locale); return df.format(date); } /** Format: 5/14/08 */ public static String formatShortUsa(Date date) { String countryCode = "US"; String languageCode = "en"; int format = DateFormat.SHORT; return convertToLocalized(date, countryCode, languageCode, format); }
This notebook is a collection of code snippets and technical "how to" instructions.
Search This Blog
Java Date
by: Zainab Aziz
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment