Calendar 获得当前时间

作者在 2010-05-23 19:30:45 发布以下内容
    public String getTime(){
        Calendar c = new GregorianCalendar();
        String time = c.get(Calendar.YEAR) + "-" +
                      (c.get(Calendar.MONTH) + 1) + "-" +
                      c.get(Calendar.DATE)  + "  " ;
        int h = c.get(Calendar.HOUR_OF_DAY);
        int m = c.get(Calendar.MINUTE);
        int s = c.get(Calendar.SECOND);
        String ph = h<10 ? "0":"";
        String pm = m<10 ? "0":"";
        String ps = s<10 ? "0":"";        
        time += ph + h + ":" + pm + m + ":" + ps + s;
        return time;
    }    
专业文章 | 阅读 1132 次
文章评论,共0条
游客请输入验证码
浏览290880次