01: /**********************************************************************************
02:
03: Feedzeo!
04: A free and open source RSS/Atom/RDF feed aggregator
05:
06: Copyright (C) 2005-2006 Anand Rao (anandrao@users.sourceforge.net)
07:
08: This library is free software; you can redistribute it and/or
09: modify it under the terms of the GNU Lesser General Public
10: License as published by the Free Software Foundation; either
11: version 2.1 of the License, or (at your option) any later version.
12:
13: This library is distributed in the hope that it will be useful,
14: but WITHOUT ANY WARRANTY; without even the implied warranty of
15: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: Lesser General Public License for more details.
17:
18: You should have received a copy of the GNU Lesser General Public
19: License along with this library; if not, write to the Free Software
20: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21:
22: ************************************************************************************/package util;
23:
24: import java.util.*;
25:
26: public class DateUtil {
27: private static String[] Months = { "Jan", "Feb", "Mar", "Apr",
28: "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
29:
30: private static String getDateSuffix(int i) {
31: switch (i) {
32: case 1:
33: case 21:
34: case 31:
35: return ("st");
36:
37: case 2:
38: case 22:
39: return ("nd");
40:
41: case 3:
42: case 23:
43: return ("rd");
44:
45: case 4:
46: case 5:
47: case 6:
48: case 7:
49: case 8:
50: case 9:
51: case 10:
52: case 11:
53: case 12:
54: case 13:
55: case 14:
56: case 15:
57: case 16:
58: case 17:
59: case 18:
60: case 19:
61: case 20:
62: case 24:
63: case 25:
64: case 26:
65: case 27:
66: case 28:
67: case 29:
68: case 30:
69: return ("th");
70: default:
71: return ("");
72: }
73: }
74:
75: public static String getMonthDayYearStr(Date d) {
76: //getYear() returns year as (1900-year) represented by this date
77: // hence add 1900
78: return (Months[d.getMonth()] + " " + d.getDate()
79: + getDateSuffix(d.getDate()) + " " + (d.getYear() + 1900));
80: }
81: }
|