posts - 325,  comments - 25,  trackbacks - 0

 //取系统日期
    public String getDateWithString() {
        Calendar now = Calendar.getInstance();
        int month = now.get(Calendar.MONTH) + 1;
        int day = now.get(Calendar.DAY_OF_MONTH);
        int year = now.get(Calendar.YEAR);
        String result = year + " 年 " + month + " 月 " + day + " 日 ";
        return result;
    }

    //取系统日期
    public String getDateWithYMD() {
        Calendar now = Calendar.getInstance();
        int month = now.get(Calendar.MONTH) + 1;
        int day = now.get(Calendar.DAY_OF_MONTH);
        int year = now.get(Calendar.YEAR);
        String date = year + "-" + month + "-" + day;
        return date;
    }

    //取系统日期
    public String getDateWithNum() {
        Calendar now = Calendar.getInstance();
        int year = now.get(Calendar.YEAR);
        int month = now.get(Calendar.MONTH) + 1;
        int day = now.get(Calendar.DAY_OF_MONTH);
        String smonth = "" + month;
        String sday = "" + day;
        if (month < 10) {
            smonth = "0" + month;
        }
        if (day < 10) {
            sday = "0" + day;
        }
        String date = year + smonth + sday;
        return date;
    }

    //取系统日期
    public Date getDate() {
        Calendar now = Calendar.getInstance();
        int month = now.get(Calendar.MONTH) + 1;
        int day = now.get(Calendar.DAY_OF_MONTH);
        int year = now.get(Calendar.YEAR);
        String date = year + "-" + month + "-" + day;
        Date result = Date.valueOf(date);
        return result;
    }

posted on 2008-08-27 23:51 长春语林科技 阅读(7637) 评论(0)  编辑  收藏 所属分类: java

只有注册用户登录后才能发表评论。


网站导航:
 
<2008年8月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

 

长春语林科技欢迎您!

常用链接

留言簿(6)

随笔分类

随笔档案

文章分类

文章档案

相册

收藏夹

搜索

  •  

最新评论

阅读排行榜

评论排行榜