So I have a custom tag that currently works, but I would like to change it from the current date to show the date and the current time.
this is what I have as an output Current Date/Time: Monday, March 31, 2014
<%@ tag language="java" pageEncoding="ISO-8859-1"%>
<%@ tag import="java.util.Date" import="java.text.DateFormat"%>
<%
DateFormat dateFormat =
DateFormat.getDateInstance(DateFormat.FULL);
Date now = new Date(System.currentTimeMillis());
out.println(dateFormat.format(now));
%>
If you want the time as well use the getDateTimeInstance()
method or for more flexibility use the SimpleDateFromat
http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
By the way, the Date constructor new Date ()
will obtain the current date, you do not need to pass System.currentTimeMillis()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.