The list is acting funny today...rejects everytime I
send.
I am conerned with getting the Day of the Month. Most
important question labeled with **.
Right now I can format the date by doing something
like:
===========
Query:
===========
...
Date x = myResultSet.getDate(3)
...
===========
Code:
===========
Date d = new Date();
SimpleDateFormat datef, timef;
datef = new SimpleDateFormat("MMM dd yyyy");
timef = new SimpleDateFormat("HH:mm")
int days;
int months;
int years;
days = d.getDay();
months = d.getMonth();
years = d.getYear();
===========
Display method:
===========
<td><%= datef.format(x) %> to display formatted date
<td><%= days %>
<td><%= Months %>
<td><%= Years %>
===========
Questions:
===========
1. myResultSet.getDate() yields date only and
myResultSet.getTime() yields time only. How do I
display both since my field contains both? (When I do
Object o = myResultSet.getObject() it shows date and
shows place holder for time but time is 00:00:00.)
**2.How do I get a numeric Day of the Month instead of
day of week? Days yields 1-7. I need 1-31 or
whatever it is for each month.** (This is most
important)
3. years = d.getYear() yields "100" since it is
century or something. How do I display the year 2000
as numeric?
What I am trying to do is compare today's date to a
date on the database. If the date is older than say 5
days then do something, if the day is today then do
something else, etc...)
Help needed ASAP!!! Thanks, Dan
--- Magesh CS <[EMAIL PROTECTED]> wrote:
> Can u get the object as
>
> Object o = resultset.getObject(n);
>
> and manipulate it later.
>
>
> --- Dan Lopez <[EMAIL PROTECTED]> wrote:
> > 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
>
>
> __________________________________________________
> 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
__________________________________________________
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