Show Current Date in JSP Page

In this example, We will show sample program about, How to show current date in JSP page. This example has been tested with apache tomcat server environment and output has been shared in the same post.

Example Program

<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Today Date</title>
// defining the variable
Date currentDate;
String formattedDate;
// creating the date object
currentDate = new Date();
// creating the dateformet object
DateFormat df = new SimpleDateFormat("EE, MMMM dd, YYYY");
// formatting the date (ie: Thu, March 05, 2015)
formattedDate = df.format(currentDate);
<h1>Hello, Today`s Date is : <%=formattedDate %></h1>


How to Show Current Date in JSP Page


1. Getting Current Date using Java

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *