home *** CD-ROM | disk | FTP | other *** search
- package cal;
-
- import java.util.Calendar;
- import java.util.Date;
-
- public class JspCalendar {
- Calendar calendar = null;
- Date currentDate;
-
- public JspCalendar() {
- this.calendar = Calendar.getInstance();
- Date trialTime = new Date();
- this.calendar.setTime(trialTime);
- }
-
- public int getYear() {
- return this.calendar.get(1);
- }
-
- public String getMonth() {
- int m = this.getMonthInt();
- String[] months = new String[]{"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
- return m > 12 ? "Unknown to Man" : months[m - 1];
- }
-
- public String getDay() {
- int x = this.getDayOfWeek();
- String[] days = new String[]{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
- return x > 7 ? "Unknown to Man" : days[x - 1];
- }
-
- public int getMonthInt() {
- return 1 + this.calendar.get(2);
- }
-
- public String getDate() {
- return this.getMonthInt() + "/" + this.getDayOfMonth() + "/" + this.getYear();
- }
-
- public String getCurrentDate() {
- Date dt = new Date();
- this.calendar.setTime(dt);
- return this.getMonthInt() + "/" + this.getDayOfMonth() + "/" + this.getYear();
- }
-
- public String getNextDate() {
- this.calendar.set(5, this.getDayOfMonth() + 1);
- return this.getDate();
- }
-
- public String getPrevDate() {
- this.calendar.set(5, this.getDayOfMonth() - 1);
- return this.getDate();
- }
-
- public String getTime() {
- return this.getHour() + ":" + this.getMinute() + ":" + this.getSecond();
- }
-
- public int getDayOfMonth() {
- return this.calendar.get(5);
- }
-
- public int getDayOfYear() {
- return this.calendar.get(6);
- }
-
- public int getWeekOfYear() {
- return this.calendar.get(3);
- }
-
- public int getWeekOfMonth() {
- return this.calendar.get(4);
- }
-
- public int getDayOfWeek() {
- return this.calendar.get(7);
- }
-
- public int getHour() {
- return this.calendar.get(11);
- }
-
- public int getMinute() {
- return this.calendar.get(12);
- }
-
- public int getSecond() {
- return this.calendar.get(13);
- }
-
- public int getEra() {
- return this.calendar.get(0);
- }
-
- public String getUSTimeZone() {
- String[] zones = new String[]{"Hawaii", "Alaskan", "Pacific", "Mountain", "Central", "Eastern"};
- return zones[10 + this.getZoneOffset()];
- }
-
- public int getZoneOffset() {
- return this.calendar.get(15) / 3600000;
- }
-
- public int getDSTOffset() {
- return this.calendar.get(16) / 3600000;
- }
-
- public int getAMPM() {
- return this.calendar.get(9);
- }
- }
-