Right now I do something like this for an example:

<%@ page import="java.util.*,
java.text.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);

                        int hours;
                        hours = tim.getHours();
                        int days;
                        days = tim.getDay();
%>

The current date at the server is <%= tim %>.

<hr>

Display date only: <%= datef.format(tim) %>

<hr>

Display numeric value of the day of the week only
(i.e. Thursday = 4):  <%= days %>

<hr>

Display comparison of numeric conversion days of the
week:
  <% if (days > 1) { %>
  <br>Text is <font
color="Orange"><b>orange</b></font> but could be row
color   <% } %>
  <% if (days == 3) { %>
  <br>Text is <font color="#0033ff"><b>blue</b></font>

but could be row color, etc
  <% } %>
  <% if (days < 5) { %>
  <br>Text is <font color="Red"><b>red</b></font> but
could be row color
  <% } %>

<hr>

Display time only: <%= timef.format(tim) %>

And so forth...All works fine.  But I cant seem to be
able to compare values of that date and the date from
the database.

So how should I change my page objective (ie
java.util*) to be able to do date arithmetic?  My SQL
query gets a value like "Oct 1 2000 12:00AM" as a
smalldatetime.

I think the way I did it in JSP looks like "TUES OCT 2
2000 GMT 1200AM."

Suggestions?????





--- Ajit Bhingarkar <[EMAIL PROTECTED]> wrote:
> 1. First you have to create a proper util.Date
> object
> by parsing the date string selected in the table.
> You can use standard parsers. Refer to java.text.
> 2. You then have to get the java.util.Calendar
> object for the
> Date so created. This class has many util methods to
> compare, add to, subtract from the your Date.
> You can also set individual attributes like day of
> the week,
> day of the month, month of the year etc.
>
> Hope this helps ..
>
> - Ajit
>
> Dan Lopez wrote:
> >
> > I am selecting smalldatetime field from a table in
> my
> > db. I would like to know how to compare the date
> > values in the query to certain criteria (eg 48
> hours
> > ago, 10 days from now, etc...) that I specify in
> my
> > JSP code and then display.  Please help!!!!!!!!
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Photos - 35mm Quality Prints, Now Get 15
> Free!
> > http://photos.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


__________________________________________________
Do You Yahoo!?
Yahoo! Photos - 35mm Quality Prints, Now Get 15 Free!
http://photos.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

Reply via email to