jsp用java运行当前时间 您所在的位置:网站首页 jsp输出当前系统时间 jsp用java运行当前时间

jsp用java运行当前时间

2024-01-04 00:07| 来源: 网络整理| 查看: 265

JSP显示当前系统时间的四种方式:

第一种java内置时间类实例化对象:

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

My JSP 'time4.jsp' starting page

java.text.SimpleDateFormat simpleDateFormat = new java.text.SimpleDateFormat(

"yyyy-MM-dd HH:mm:ss");

java.util.Date currentTime = new java.util.Date();

String time = simpleDateFormat.format(currentTime).toString();

out.println("当前时间为:"+time);

%>

第二种方式使用JSP内置USEBEAN实例化时间类:

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

显示系统时间


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有