Back to project page Ocypode.
The source code is released under:
MIT License
If you think the Android project Ocypode 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.ocypode.utility.formatter; //from w w w . j a v a 2s. co m import java.text.SimpleDateFormat; import java.util.Locale; public class DateFormatter { public static CharSequence getDayWithSuffix(int day) { if (day >= 1 && day <= 31) { if (day >= 11 && day <= 13) { return day + "th"; } switch (day % 10) { case 1: return day + "st"; case 2: return day + "nd"; case 3: return day + "rd"; default: return day + "th"; } } throw new IllegalArgumentException("The day of the month should be between 1 and 31."); } public static SimpleDateFormat simpleDateFormat(String pattern){ try { return new SimpleDateFormat(pattern, Locale.getDefault()); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Pattern invalid date."); } } }