struts中的常量类(date)
这些东西经常用,贴出来以便查询。
1、struts中的常量类(时间<1>)
package struts.news;

import java.text.*;
import java.util.*;
public final class Constants {
// Session keys
    public static final String DATASOURCE_KEY =
"mysqlDB";
    public static final String LOGIN_USERNAME_KEY =
"username";
    public static final String NEWS_LIST_KEY =
"newslist";
    public static final String NEWS_DETAIL_KEY =
"newsDetail";
              
//system date
    public static final String getDate(){
Calendar cal = Calendar.getInstance();
java.text.SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
        String cdate = sdf.format(cal.getTime());
        
//System.out.println("times is :"+cdate);
return cdate;
}
}
2、时间<2>
java.util.Date date=new java.util.Date();
int yyyy=1900+date.getYear();
int mm=date.getMonth()+1;
int dd=date.getDate();
int hh=date.getHours();
int mi=date.getMinutes();
int ss=date.getSeconds();
String theDate= yyyy+
"-"+mm+"-"+dd;
String theDates= yyyy+
"-"+mm+"-"+dd+" "+hh+":"+mi+":"+ss;
lunzi   2006-06-16 19:20:34 评论:0   阅读:1473   引用:0

发表评论>>

署名发表(评论可管理,不必输入下面的姓名)

姓名:

主题:

内容: 最少15个,最长1000个字符

验证码: (如不清楚,请刷新)

Copyright@2004-2010 powered by YuLog