Source Code Cross Referenced for Calendar.java in  » Groupware » hipergate » com » knowgate » misc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » hipergate » com.knowgate.misc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:          Copyright (C) 2003  Know Gate S.L. All rights reserved.
003:                              C/Oña, 107 1º2 28050 Madrid (Spain)
004:
005:          Redistribution and use in source and binary forms, with or without
006:          modification, are permitted provided that the following conditions
007:          are met:
008:
009:          1. Redistributions of source code must retain the above copyright
010:             notice, this list of conditions and the following disclaimer.
011:
012:          2. The end-user documentation included with the redistribution,
013:             if any, must include the following acknowledgment:
014:             "This product includes software parts from hipergate
015:             (http://www.hipergate.org/)."
016:             Alternately, this acknowledgment may appear in the software itself,
017:             if and wherever such third-party acknowledgments normally appear.
018:
019:          3. The name hipergate must not be used to endorse or promote products
020:             derived from this software without prior written permission.
021:             Products derived from this software may not be called hipergate,
022:             nor may hipergate appear in their name, without prior written
023:             permission.
024:
025:          This library is distributed in the hope that it will be useful,
026:          but WITHOUT ANY WARRANTY; without even the implied warranty of
027:          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
028:
029:          You should have received a copy of hipergate License with this code;
030:          if not, visit http://www.hipergate.org or mail to info@hipergate.org
031:         */
032:
033:        package com.knowgate.misc;
034:
035:        import com.knowgate.debug.DebugFile;
036:
037:        /**
038:         * <p>Calendar localization functions</p>
039:         * @author Sergio Montoro Ten
040:         * @version 2.0
041:         */
042:
043:        public class Calendar {
044:
045:            private static String WeekDayNamesES[] = { null, "domingo",
046:                    "lunes", "martes", "miércoles", "jueves", "viernes",
047:                    "sábado" };
048:            private static String WeekDayNamesEN[] = { null, "Sunday",
049:                    "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
050:                    "Saturday" };
051:            private static String WeekDayNamesIT[] = { null, "Domenica",
052:                    "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì",
053:                    "Sabato" };
054:            private static String WeekDayNamesFR[] = { null, "Dimanche",
055:                    "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi" };
056:            private static String WeekDayNamesDE[] = { null, "Sonntag",
057:                    "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag",
058:                    "Samstag" };
059:            private static String WeekDayNamesPT[] = { null, "Domingo",
060:                    "Segunda-feira", "Terça-feira", "Quarta-feira",
061:                    "Quinta-feira", "Sexta-feira", "Sábado" };
062:
063:            private static String MonthNamesES[] = { "Enero", "Febrero",
064:                    "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto",
065:                    "Septiembre", "Octubre", "Noviembre", "Diciembre" };
066:            private static String MonthNamesEN[] = { "January", "February",
067:                    "March", "April", "May", "June", "July", "August",
068:                    "September", "October", "November", "December" };
069:            private static String MonthNamesIT[] = { "Gennaio", "Febbraio",
070:                    "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto",
071:                    "Settembre", "Ottobre", "Novembre", "Dicembre" };
072:            private static String MonthNamesFR[] = { "Janvier", "Février",
073:                    "Mars", "Avril", "Mai", "Juin", "Juillet", "Août",
074:                    "Septembre", "Octobre", "Novembre", "Décembre" };
075:            private static String MonthNamesDE[] = { "Januar", "Februar",
076:                    "März", "April", "Mai", "Juni", "Juli", "August",
077:                    "September", "Oktober", "November", "Dezember" };
078:            private static String MonthNamesPT[] = { "Janeiro", "Fevereiro",
079:                    "Março", "Abril", "Maio", "Junho", "Julho", "Agosto",
080:                    "Setembro", "Outubro", "Novembro", "Dezembro" };
081:
082:            private static String MonthNamesRFC[] = { "Jan", "Feb", "Mar",
083:                    "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
084:                    "Dec" };
085:
086:            //-----------------------------------------------------------
087:
088:            /**
089:             * Get translated week day name
090:             * @param MyWeekDay [1=Sunday .. 7=Saturday]
091:             * @param sLangId 2 characters language identifier (currently only { "en","es","it","fr","de" and "pt" } are supported)
092:             * @return Week day name
093:             */
094:            public static String WeekDayName(int MyWeekDay, String sLangId) {
095:
096:                if (DebugFile.trace) {
097:                    DebugFile.writeln("Begin WeekDayName("
098:                            + String.valueOf(MyWeekDay) + "," + sLangId + ")");
099:                    DebugFile.incIdent();
100:                }
101:
102:                String sRetVal;
103:
104:                if (MyWeekDay < 1 || MyWeekDay > 7)
105:                    throw new java.lang.IllegalArgumentException(
106:                            "Calendar.WeekDayName 1st parameter (MyWeekDay) is "
107:                                    + String.valueOf(MyWeekDay)
108:                                    + " but must be in the range [1..7]");
109:                else {
110:                    if (null == sLangId)
111:                        throw new java.lang.IllegalArgumentException(
112:                                "Calendar.WeekDayName 2nd parameter (Language Id.) is null but must be one of {es,en}");
113:                    else if (sLangId.equalsIgnoreCase("es"))
114:                        sRetVal = WeekDayNamesES[MyWeekDay];
115:                    else if (sLangId.equalsIgnoreCase("en"))
116:                        sRetVal = WeekDayNamesEN[MyWeekDay];
117:                    else if (sLangId.equalsIgnoreCase("fr"))
118:                        sRetVal = WeekDayNamesFR[MyWeekDay];
119:                    else if (sLangId.equalsIgnoreCase("de"))
120:                        sRetVal = WeekDayNamesDE[MyWeekDay];
121:                    else if (sLangId.equalsIgnoreCase("it"))
122:                        sRetVal = WeekDayNamesIT[MyWeekDay];
123:                    else if (sLangId.equalsIgnoreCase("pt"))
124:                        sRetVal = WeekDayNamesPT[MyWeekDay];
125:                    else
126:                        throw new java.lang.IllegalArgumentException(
127:                                "Calendar.WeekDayName 2nd parameter (Language Id.) must be one of {es,en}");
128:                }
129:
130:                if (DebugFile.trace) {
131:                    DebugFile.decIdent();
132:                    DebugFile.writeln("End WeekDayName() : " + sRetVal);
133:                }
134:
135:                return sRetVal;
136:            } // WeekDay
137:
138:            //-----------------------------------------------------------
139:
140:            /**
141:             * Get translated month name
142:             * @param MyMonth [0=January .. 11=December]
143:             * @param sLangId sLangId 2 characters language identifier (currently only  { "en","es","it","fr","de" and "pt" } are supported)
144:             * @return Month Name
145:             */
146:            public static String MonthName(int MyMonth, String sLangId) {
147:
148:                if (DebugFile.trace) {
149:                    DebugFile.writeln("Begin MonthName("
150:                            + String.valueOf(MyMonth) + "," + sLangId + ")");
151:                    DebugFile.incIdent();
152:                }
153:
154:                String sRetVal;
155:
156:                if (MyMonth < 0 || MyMonth > 11)
157:                    throw new java.lang.IllegalArgumentException(
158:                            "Calendar.MonthName 1st parameter (MyMonth) is "
159:                                    + String.valueOf(MyMonth)
160:                                    + " but must be in the range [0..11]");
161:                else {
162:                    if (null == sLangId)
163:                        throw new java.lang.IllegalArgumentException(
164:                                "Calendar.MonthName 2nd parameter (Language Id.) is null but must be one of {es,en}");
165:                    else if (sLangId.equalsIgnoreCase("es"))
166:                        sRetVal = MonthNamesES[MyMonth];
167:                    else if (sLangId.equalsIgnoreCase("en"))
168:                        sRetVal = MonthNamesEN[MyMonth];
169:                    else if (sLangId.equalsIgnoreCase("fr"))
170:                        sRetVal = MonthNamesFR[MyMonth];
171:                    else if (sLangId.equalsIgnoreCase("it"))
172:                        sRetVal = MonthNamesIT[MyMonth];
173:                    else if (sLangId.equalsIgnoreCase("de"))
174:                        sRetVal = MonthNamesDE[MyMonth];
175:                    else if (sLangId.equalsIgnoreCase("pt"))
176:                        sRetVal = MonthNamesPT[MyMonth];
177:                    else
178:                        throw new java.lang.IllegalArgumentException(
179:                                "Calendar.WeekDayName 2nd parameter (Language Id.) must be one of {es,en}");
180:                }
181:
182:                if (DebugFile.trace) {
183:                    DebugFile.decIdent();
184:                    DebugFile.writeln("End MonthName() : " + sRetVal);
185:                }
186:
187:                return sRetVal;
188:            } // MonthName
189:
190:            //-----------------------------------------------------------
191:
192:            /**
193:             * Get Month Last Day
194:             * @param MyMonth [0=January .. 11=December]
195:             * @param MyYear 4 digits year
196:             * @return the last day of the month. Takes into account leap years
197:             */
198:            public static int LastDay(int MyMonth, int MyYear) {
199:
200:                if (MyMonth < 0 || MyMonth > 11)
201:                    throw new java.lang.IllegalArgumentException(
202:                            "Calendar.LastDay 1st parameter (MyMonth) is "
203:                                    + String.valueOf(MyMonth)
204:                                    + " but must be in the range [0..11]");
205:
206:                if (MyYear < 1000 || MyYear > 9999)
207:                    throw new java.lang.IllegalArgumentException(
208:                            "Calendar.LastDay 2nd parameter (MyYear) is "
209:                                    + String.valueOf(MyYear)
210:                                    + " but must be in the range [1000..9999]");
211:
212:                switch (MyMonth) {
213:                case 0:
214:                case 2:
215:                case 4:
216:                case 6:
217:                case 7:
218:                case 9:
219:                case 11:
220:                    return 31;
221:                case 3:
222:                case 5:
223:                case 8:
224:                case 10:
225:                    return 30;
226:                case 1:
227:                    return ((MyYear % 400 == 0) || ((MyYear % 4 == 0) && (MyYear % 100 != 0))) ? 29
228:                            : 28;
229:                } // end switch()
230:                return 0;
231:            } // LastDay()
232:
233:            //-----------------------------------------------------------
234:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.