It's really a matter of cleaning up your imports so you don't have the name
collision. I'd suggest not importing "java.util.*". When you need to
declare a java.util.Date, use the full class name. I'd also suggest using
the full class name when declaring a java.sql.Date as well, just for
readability.
Most people don't understand just how little effect the import keyword has
on what the compiler is doing. It's even more trivial in the case of a JSP,
which is small enough that you could easily just import nothing and use all
fully-qualified names without much more effort.
At any rate, java.sql.Date is a subclass of java.util.Date, so you should be
able to format it with the regular java.text format guys, once you iron out
your naming problems. Ditto for the date arithmetic, if you want to do it
outside the dbms.
Mike
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Dan Lopez
Sent: Thursday, October 19, 2000 11:23 AM
To: [EMAIL PROTECTED]
Subject: Re: [JSP-INTEREST] ResultSet Type
I am trying to query a simpledatetime field in my db.
I have a problem with Date type in JSP code. I import
java.sql.* and Date and Time work fine. However when
I try to import java.util.* and
java.text.SimpleDateFormat for formating date, time
and locale, I get error since java.sql.* and
java.util.* both import Date.
I can do something like this for date formating alone
and it works for me with util and SimpleDateFormat:
<%
SimpleDateFormat datef, timef;
Date tim = new Date();
Locale fi = new Locale("fi", "FI");
datef = new SimpleDateFormat("MM-dd-yyyy", fi);
timef = new SimpleDateFormat("HH:mm:ss", fi);
%>
Display formatted date only:<%= datef.format(tim) %>
But here I display query resultset with java.sql.* in
which I can do Date or Time and not both:
<%
if (myResultSet != null) {
while (myResultSet.next()) {
Date x = myResultSet.getDate(n);
...
or
Time x = myResultSet.getTime(n);
...
1.How do I display both time and date?
2.How do I format date?
3.How is date arithmetic done in JSP? on DB side or in
JSP code?
**Note I display as**
<table>
<tr>
<td><%= x %>
</tr>
</table>
__________________________________________________
Do You Yahoo!?
Yahoo! Messenger - Talk while you surf! It's FREE.
http://im.yahoo.com/
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets