获取当前时间放到页面

DateFormat dateFormatterChina = DateFormat.getDateInstance();//格式化输出  

        TimeZone timeZoneChina = TimeZone.getTimeZone("Asia/Shanghai");//获取时区  

        dateFormatterChina.setTimeZone(timeZoneChina);//设置系统时区  

Date date =new Date();//创建Data对象实例

String time= dateFormatterChina.format(date);

request.setAttribute("time", time);//放到request作用域中

发布了15 篇原创文章 · 获赞 16 · 访问量 2万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章