Greetings,
I have the following code below which allows the date to be added via a JDBC connection as a STRING.
The value of dateString is inserted into the MS ACCESS database.
What is the easiest method to add the current date/time (dd/mm/yy hh:mm:ss) via JDBC in DATE format i.e. convert STRING to DATE or format the DATE without changing its type and insert it.
I'm a newbie to Java/Jsp too.
I have the following code below which allows the date to be added via a JDBC connection as a STRING.
The value of dateString is inserted into the MS ACCESS database.
What is the easiest method to add the current date/time (dd/mm/yy hh:mm:ss) via JDBC in DATE format i.e. convert STRING to DATE or format the DATE without changing its type and insert it.
I'm a newbie to Java/Jsp too.
Code:
<%@ page import="java.util.Date, java.text.SimpleDateFormat" %>
<% java.util.Locale locale = request.getLocale(); %>
<%
Date d = new Date();
String dateString = getFormattedDate (d);
%>
<%!
String getFormattedDate(Date d)
{
SimpleDateFormat simpleDate = new SimpleDateFormat("dd/MM/yy hh:mm:ss");
return simpleDate.format(d);
}
%>
Comment