public class Jspcalendar {
Calendar calendar = null;
Public Jspcalendar () {
Calendar = Calendar.getinstance ();
Date Trialtime = new Date ();
Calendar.settime (Trialtime);
}
public int getyear () {
Return Calendar.get (calendar.year);
}
Public String getmonth () {
int m = Getmonthint ();
string[] months = new String [] {"January", "February", "March",
"April", "may", "June",
"July", "August", "September",
"October", "November", "December"};
if (M > 12)
Return "Unknown to Man";
return months[m-1];
}
Public String getday () {
int x = GetDayOfWeek ();
String[] days = new string[] {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"};
if (x > 7)
Return "Unknown to Man";
return days[x-1];
}
public int Getmonthint () {
Return 1 + calendar.get (calendar.month);
}
public int GetDayOfMonth () {
Return Calendar.get (Calendar.day_of_month);
}
public int getdayofyear () {
Return Calendar.get (calendar.day_of_year);
}
public int getweekofyear () {
Return Calendar.get (calendar.week_of_year);
}
public int Getweekofmonth () {
Return Calendar.get (Calendar.week_of_month);
}
public int GetDayOfWeek () {
Return Calendar.get (Calendar.day_of_week);
}
public int Gethour () {
Return Calendar.get (Calendar.hour_of_day);
}
public int Getminute () {
Return Calendar.get (Calendar.minute);
}
public int Getsecond () {
Return Calendar.get (Calendar.second);
}
public static void Main (String args[]) {
Jspcalendar db = new Jspcalendar ();
P ("Date:" + db.getdayofmonth ());
P ("Year:" + db.getyear ());
P ("Month:" + db.getmonth ());
P ("Time:" + db.gettime ());
P ("Date:" + db.getdate ());
P ("Day:" + db.getday ());
P ("DayOfYear:" + db.getdayofyear ());
P ("WeekOfYear:" + db.getweekofyear ());
P ("era:" + Db.getera ());
P ("AMPM:" + db.getampm ());
P ("DST:" + db.getdstoffset ());
P ("ZONE Offset:" + db.getzoneoffset ());
P ("TIMEZONE:" + db.getustimezone ());
}
private static void P (String x) {
SYSTEM.OUT.PRINTLN (x);
}
public int Getera () {
Return Calendar.get (Calendar.era);
}
Public String Getustimezone () {
string[] zones = new string[] {"Hawaii", "Alaskan", "Pacific",
"Mountain", "a", "Eastern"};
return zones[10 + Getzoneoffset ()];
}
public int Getzoneoffset () {
Return Calendar.get (Calendar.zone_offset)/(60*60*1000);
}
public int Getdstoffset () {
Return Calendar.get (Calendar.dst_offset)/(60*60*1000);
}
public int getampm () {
Return Calendar.get (CALENDAR.AM_PM);
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.