|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
在ruby里才是一切皆对象。当然我不并不是很了解ruby,但是ruby确实是将语法简化得很好。对照importjava.text.DateFormat;
importjava.util.*;
publicclassJspCalendar{
Calendarcalendar=null;
publicJspCalendar(){
calendar=Calendar.getInstance();
DatetrialTime=newDate();
calendar.setTime(trialTime);
}
publicintgetYear(){
returncalendar.get(Calendar.YEAR);
}
publicStringgetMonth(){
intm=getMonthInt();
String[]months=newString[]{"January","February","March",
"April","May","June",
"July","August","September",
"October","November","December"};
if(m>12)
return"UnknowntoMan";
returnmonths[m-1];
}
publicStringgetDay(){
intx=getDayOfWeek();
String[]days=newString[]{"Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday"};
if(x>7)
return"UnknowntoMan";
returndays[x-1];
}
publicintgetMonthInt(){
return1+calendar.get(Calendar.MONTH);
}
publicStringgetDate(){
returngetMonthInt()+"/"+getDayOfMonth()+"/"+getYear();
}
publicStringgetTime(){
returngetHour()+":"+getMinute()+":"+getSecond();
}
publicintgetDayOfMonth(){
returncalendar.get(Calendar.DAY_OF_MONTH);
}
publicintgetDayOfYear(){
returncalendar.get(Calendar.DAY_OF_YEAR);
}
publicintgetWeekOfYear(){
returncalendar.get(Calendar.WEEK_OF_YEAR);
}
publicintgetWeekOfMonth(){
returncalendar.get(Calendar.WEEK_OF_MONTH);
}
publicintgetDayOfWeek(){
returncalendar.get(Calendar.DAY_OF_WEEK);
}
publicintgetHour(){
returncalendar.get(Calendar.HOUR_OF_DAY);
}
publicintgetMinute(){
returncalendar.get(Calendar.MINUTE);
}
publicintgetSecond(){
returncalendar.get(Calendar.SECOND);
}
publicstaticvoidmain(Stringargs[]){
JspCalendardb=newJspCalendar();
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("ZONEOffset:"+db.getZoneOffset());
p("TIMEZONE:"+db.getUSTimeZone());
}
privatestaticvoidp(Stringx){
System.out.println(x);
}
publicintgetEra(){
returncalendar.get(Calendar.ERA);
}
publicStringgetUSTimeZone(){
String[]zones=newString[]{"Hawaii","Alaskan","Pacific",
"Mountain","Central","Eastern"};
returnzones[10+getZoneOffset()];
}
publicintgetZoneOffset(){
returncalendar.get(Calendar.ZONE_OFFSET)/(60*60*1000);
}
publicintgetDSTOffset(){
returncalendar.get(Calendar.DST_OFFSET)/(60*60*1000);
}
publicintgetAMPM(){
returncalendar.get(Calendar.AM_PM);
}
}
一旦你有了思想,那你编的程序就有了灵魂,不管是什么语言到了你的手里都会是你的工具而已,他们的价值是能尽快帮助你实现你想要的目标。但是如果你没有了思想,那就像是海里的帆船失去了船帆,是很难到打海的另一边的。 |
|