Hello All,

I am new to JSP. Currently i am working on jsp project with mysql.
I got stucked with jsp date and time which supports mysql datetime format.

Please come up with your suggestions.
Thanks in Advance.

SHANTI.

Recommended Answers

All 4 Replies

please explain what type of calculation you want to do with your date time

Member Avatar for rakhi4110

kindly be more specific with your problem.
One solution which i can give you is the use of java.util.DateFormat class

<%@ page import="java.text.*,java.util.*" session="true"%>
<html>
<head><title>Date Format Example</title></head>
<%!
DateFormat date = DateFormat.getDateInstance
(DateFormat.FULL, Locale.US);
String result = date.format(new Date());
%>
<b>Today's date is: <%= result %></b>
Member Avatar for rakhi4110

The DateFormat class also provides different styles like FULL, LONG, MEDIUM, SHORT.

FULL- it specifies completely, such as Wednesday, July 9, 2008 AD or 6:13pm.
LONG- it specifies as July 9, 2008 or 6:13pm.
MEDIUM - it specifies as Jul 9,2008.
SHORT - it specifies as 09.07.08 or 6:13pm

Thanks all....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.