获取当前时间放到页面

来源:互联网 发布:老凤祥淘宝上怎么没了 编辑:程序博客网 时间:2024/06/07 12:11

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作用域中

原创粉丝点击