Source Code Cross Referenced for CalendarUtil.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » util » 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 » ERP CRM Financial » sakai » org.sakaiproject.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/calendar/tags/sakai_2-4-1/calendar-util/util/src/java/org/sakaiproject/util/CalendarUtil.java $
003:         * $Id: CalendarUtil.java 8050 2006-04-20 17:39:55Z ggolden@umich.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007:         * 
008:         * Licensed under the Educational Community License, Version 1.0 (the "License"); 
009:         * you may not use this file except in compliance with the License. 
010:         * You may obtain a copy of the License at
011:         * 
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         * 
014:         * Unless required by applicable law or agreed to in writing, software 
015:         * distributed under the License is distributed on an "AS IS" BASIS, 
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
017:         * See the License for the specific language governing permissions and 
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.sakaiproject.util;
021:
022:        import java.util.Calendar;
023:
024:        /**
025:         * <p>CalendarUtil is a bunch of utility methods added to a java Calendar object.</p>
026:         */
027:        public class CalendarUtil {
028:            /** The calendar object this is based upon. */
029:            Calendar m_calendar = null;
030:
031:            /**
032:             * Construct.
033:             */
034:            public CalendarUtil() {
035:                m_calendar = Calendar.getInstance();
036:
037:            } // CalendarUtil
038:
039:            /**
040:             * Access the current user.
041:             * @return the current year.
042:             */
043:            public int getYear() {
044:                return m_calendar.get(Calendar.YEAR);
045:
046:            } // getYear
047:
048:            /**
049:             * Set the calendar to the next day, and return this.
050:             * @return the next day.
051:             */
052:            public String getNextDate() {
053:                m_calendar.set(Calendar.DAY_OF_MONTH, getDayOfMonth() + 1);
054:                return getTodayDate();
055:
056:            } // getNextDate
057:
058:            public void nextDate() {
059:                m_calendar.set(Calendar.DAY_OF_MONTH, getDayOfMonth() + 1);
060:            }
061:
062:            /**
063:             * Set the calendar to the prev day, and return this.
064:             * @return the prev day.
065:             */
066:            public String getPrevDate() {
067:                m_calendar.set(Calendar.DAY_OF_MONTH, getDayOfMonth() - 1);
068:                return getTodayDate();
069:            } // getPrevDate
070:
071:            public void prevDate() {
072:                m_calendar.set(Calendar.DAY_OF_MONTH, getDayOfMonth() - 1);
073:            }
074:
075:            /**
076:             * Set the calendar to the next month, and return this.
077:             * @return the next month.
078:             */
079:            public int getNextMonth() {
080:                m_calendar.set(Calendar.MONTH, getMonthInteger());
081:
082:                setDay(getYear(), getMonthInteger(), 1);
083:
084:                return getMonthInteger();
085:
086:            } // getNextMonth
087:
088:            /**
089:             * Set the calendar to the next year, and return this.
090:             * @return the next year.
091:             */
092:            public void setNextYear() {
093:                m_calendar.set(Calendar.YEAR, getYear() + 1);
094:                setDay(getYear(), getMonthInteger(), 1);
095:
096:            } // setNextYear
097:
098:            /**
099:             * Set the calendar to the prev month, and return this.
100:             * @return the prev month.
101:             */
102:            public int getPrevMonth() {
103:                m_calendar.set(Calendar.MONTH, getMonthInteger() - 2);
104:
105:                return (getMonthInteger() - 1);
106:
107:            } // getPrevMonth	
108:
109:            /**
110:             * Set the calendar to the prev year, and return this.
111:             * @return the prev year.
112:             */
113:            public void setPrevYear() {
114:                m_calendar.set(Calendar.YEAR, getYear() - 1);
115:
116:            } // setPrevYear
117:
118:            /**
119:             * Get the day of the week.
120:             * @return the day of the week.
121:             */
122:            public int getDay_Of_Week() {
123:                return m_calendar.get(Calendar.DAY_OF_WEEK);
124:
125:            } //. getDay_Of_Week
126:
127:            /**
128:             * Set the calendar to the next week, and return this.
129:             * @return the next week.
130:             */
131:            public void setNextWeek() {
132:                m_calendar.set(Calendar.WEEK_OF_MONTH, getWeekOfMonth() + 1);
133:
134:            } // setNextWeek
135:
136:            /**
137:             * Set the calendar to the prev week, and return this.
138:             * @return the prev week.
139:             */
140:            public void setPrevWeek() {
141:                m_calendar.set(Calendar.WEEK_OF_MONTH, getWeekOfMonth() - 1);
142:
143:            } // setPrevWeek
144:
145:            /**
146:             * Get the day of the week in month.
147:             * @return the day of week in month.
148:             */
149:            public int getDayOfWeekInMonth() {
150:                return m_calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH);
151:
152:            } // getDayOfWeekInMonth
153:
154:            /**
155:             * Get the week of month.
156:             * @return the week of month.
157:             */
158:            public int getWeekOfMonth() {
159:                return m_calendar.get(Calendar.WEEK_OF_MONTH);
160:
161:            } // getWeekOfMonth
162:
163:            /**
164:             * Get the month as an int value.
165:             * @return the month as an int value.
166:             */
167:            public int getMonthInteger() {
168:                // 1 will be added here to be able to use this func alone to construct e.g adate
169:                // to get the name of the month from getMonth(), 1 must be deducted.
170:                return 1 + m_calendar.get(Calendar.MONTH);
171:
172:            } // getMonthInteger
173:
174:            /**
175:             * Get the day of month.
176:             * @return the day of month.
177:             */
178:            public int getDayOfMonth() {
179:                int dayofmonth = m_calendar.get(Calendar.DAY_OF_MONTH);
180:                return dayofmonth;
181:
182:            } // getDayOfMonth
183:
184:            /**
185:             * Get the current date, formatted.
186:             * @return the current date, formatted.
187:             */
188:            public String getTodayDate() {
189:                return getMonthInteger() + "/" + getDayOfMonth() + "/"
190:                        + getYear();
191:
192:            } // getTodayDate
193:
194:            /**
195:             * Get the number of days.
196:             * @return the number of days.
197:             */
198:            public int getNumberOfDays() {
199:                return m_calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
200:
201:            } // getNumberOfDays
202:
203:            /**
204:             * Set the calendar to this day.
205:             * @param d the day.
206:             */
207:            public void setDayOfMonth(int d) {
208:                m_calendar.set(Calendar.DAY_OF_MONTH, d);
209:
210:            } // setDayOfMonth
211:
212:            /**
213:             * Set the calendar to this month
214:             * @param d the month.
215:             */
216:            public void setMonth(int d) {
217:                m_calendar.set(Calendar.MONTH, d);
218:
219:            } // setMonth
220:
221:            /**
222:             * Set the calendar to the first day of this month, and return this day of week.
223:             * @param month The month.
224:             * @return The calendar's day of week once set to this month.
225:             */
226:            public int getFirstDayOfMonth(int month) {
227:                m_calendar.set(Calendar.MONTH, month);
228:                m_calendar.set(Calendar.DAY_OF_MONTH, 1);
229:
230:                return (getDay_Of_Week() - 1);
231:
232:            } // getFirstDayOfMonth
233:
234:            /**
235:             * Set the calendar to this day.
236:             * @param year The year.
237:             * @param month The month.
238:             * @param day The day.
239:             */
240:            public void setDay(int year, int month, int day) {
241:                m_calendar.set(year, month - 1, day);
242:
243:            } // setDay
244:
245:        } // CalendarUtil
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.