java取得当前时间。

public int gethour()
    {
    Calendar c = Calendar.getInstance();
    int hour = c.get(Calendar.HOUR_OF_DAY);
    return hour;
    }

只取小时单位,可以跟据当前时间来判断餐别。

 String ly_time = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); 

取到年月日。

 

 

 

posted @ 2013-01-15 14:44  有梦想的小人物  阅读(210)  评论(0编辑  收藏  举报