jsp显示当前系统时间
第一种方式:
<%
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);
%>
第二种方式
<%! String formatDate(Date d){
java.text.SimpleDateFormat formater=
new java.text.SimpleDateFormat("yyyy年MM月dd日");
return formater.format(d);
}
%>
<%=formatDate(new Date()) %>
完整代码:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head> <body>
<%-- <%
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);
%> --%>
<%! String formatDate(Date d){
java.text.SimpleDateFormat formater=
new java.text.SimpleDateFormat("yyyy年MM月dd日");
return formater.format(d);
}
%>
<%=formatDate(new Date()) %>
</body>
</html>
jsp显示当前时间
jsp显示当前系统时间的更多相关文章
- JS(截取字符串,显示当前系统时间yyyy-MM-dd,从文本框得到的数值计算)
截取字符串: var str = "1234567890"; var a = str.substring(0,8); //==str.substring(8)---结果:12 ...
- 示例:Servlet显示当前系统时间(时间格式化)
package com.mhb; import java.io.IOException; import java.io.PrintWriter; import java.text.SimpleDate ...
- 如何在jsp页面获取系统时间
<%@ page import="java.util.*"%> //获取系统时间必须导入的 <%@ page import="java.text.*&q ...
- wpf 窗体中显示当前系统时间
先看一下效果: 这其实是我放置了两个TextBlock,上面显示当前的日期,下面显示时间. 接下来展示一下代码: 在XAML中: <StackPanel Width="205" ...
- web页面显示当前系统时间并定时刷新
function showCurrentDate(){ var today,hour,second,minute,year,month,date; var strDate ; today=new Da ...
- js 显示当前系统时间
<div id="test"></div> <script > setInt ...
- Android学习总结——实时显示系统时间
我们都知道System.currentTimeMillis()可以获取系统当前的时间,这里要实时显示就可以开启一个线程,然后通过handler发消息,来实时的更新TextView上显示的系统时间.具体 ...
- JSP页面添加当前时间
JSP页面添加当前时间 一.时间格式化 1.引入标签 <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/js ...
- cocos2d-x在win32和iOS、android下获取当前系统时间的方法
最近在游戏里要显示当前系统时间的功能,网上一搜很多写着获取的方法,大都是如下 struct cc_timeval now; CCTime::gettimeofdayCocos2d(&now, ...
随机推荐
- SQL 删除重复记录,并保留其中一条
--查找表中多余的重复记录select * from code_xz where code in (select code from code_xz group by code having coun ...
- (五)Spring Boot之@RestController注解和ConfigurationProperties配置多个属性
一.@RestController和@Controller的区别 @RestController注解相当于@ResponseBody + @Controller合在一起的作用. 如果只是使用@Rest ...
- sqlyog无操作一段时间后重新操作会卡死问题
在使用 sqlyog 的过程中,遇到了这种情况:打开一个连接,进行了一些操作之后,过一段时间没有操作,然后再来操作会卡死一段时间,等一段时间后操作完成了继续进行其它操作,又很流畅了.但是过一段时间不操 ...
- 货币转换C
描述 人民币和美元是世界上通用的两种货币之一,写一个程序进行货币间币值转换,其中: ...
- java玩转zip压缩包
首先将相关jar包引入pom.xml中 <!-- 解压zip --> <dependency> <groupId>org.apache.ant</groupI ...
- ASE19团队项目 beta阶段 model组 scrum5 记录
本次会议于12月6日,19时30分在微软北京西二号楼sky garden召开,持续20分钟. 与会人员:Jiyan He, Lei Chai, Linfeng Qi, Xueqing Wu, Kun ...
- Image Processing and Analysis_15_Image Registration:Multi-modal volume registration by maximization of mutual information——1996
此主要讨论图像处理与分析.虽然计算机视觉部分的有些内容比如特 征提取等也可以归结到图像分析中来,但鉴于它们与计算机视觉的紧密联系,以 及它们的出处,没有把它们纳入到图像处理与分析中来.同样,这里面也有 ...
- jquery中prop,attr,data的区别
这两天翻了jq的源码,今天看到了jq关于数据存储的几个方法,遂总结一下,和小伙伴没分享一下,哪里说的不对,还望批评指正~~~ 废话不多说,直接上代码: $(function(){ $('#div1') ...
- bp算法推导过程
参考:张玉宏<深度学习之美:AI时代的数据处理与最佳实践>265-271页
- 0005SpringBoot中用Junit测试实体类中绑定yml中的值
1.编写SpringBoot的引导类 package springboot_test.springboot_test; import org.springframework.boot.SpringAp ...