tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Kilbride" <j...@kilbride.com>
Subject Re: Dates in Java
Date Fri, 06 Apr 2001 16:46:59 GMT
There's also something to be said for using a little tact. "You might get
more help posting your question on a general Java forum" -- and then
pointing the way -- is better than using three question marks and implying
that the other person's question is "so simple". Responses like this scare
new programmers off the lists.

I remember my first post...

--jeff

----- Original Message -----
From: "Milt Epstein" <mepstein@uiuc.edu>
To: <tomcat-user@jakarta.apache.org>
Sent: Friday, April 06, 2001 7:05 AM
Subject: Re: Dates in Java


> On Fri, 6 Apr 2001, Martin Mauri wrote:
>
> > Hey...don't be so rude, let the boys work their problems out...
>
> There is something to be said for keeping a list on-topic, and people
> asking questions on appropriate forums.
>
>
> > > Are we in the tomcat-user forum ???
> > > I don't see the relationship between a so simple constructor problem
> > > (which Javadoc solve quiet easily ...) and Tomcat ...
> > >
> > >
> > > Alistair Hopkins a écrit :
> > > >
> > > > try "select myDate - 7 from myTable;" in your SQL statement for a
quick
> > fix
> > > > :-)
> > > > (works on postgres, don't know about msql)
> > > >
> > > > -----Original Message-----
> > > > From: Michael Wentzel [mailto:Michael.Wentzel@aswethink.com]
> > > > Sent: Friday, April 06, 2001 12:58 PM
> > > > To: 'tomcat-user@jakarta.apache.org'
> > > > Subject: RE: Dates in Java
> > > >
> > > > I have a simple question about the Date object (or similar object)
> > > >
> > > > I have a mySQL table with a DATETIME cell. I want to get the date
from
> > this
> > > > cell
> > > >
> > > > (formatted like so: e.g.  2001-03-23 13:04:59)
> > > >
> > > >  and retrieve the date that is exactly 7 days earlier than the
retrieved
> > > > date.
> > > >
> > > > What is the easiest way to do this? I noticed a lot of method
> > deprecations
> > > > in the specs and I am having trouble using the Date object.
> > > > -----
> > > > For example,
> > > > DateTest.java:20: cannot resolve symbol
> > > > symbol  : constructor Date  ()
> > > > location: class java.sql.Date
> > > >                 Date d = new Date();
> > > >                          ^
> > > > 1 error
> > > >
> > > > -----
> > > >
> > >
> >
> --------------------------------------------------------------------------
> > --
> > > > ---------
> > > > First, in regards to displaying your date use the
java.text.DateFormat
> > > > class(note DateFormat
> > > > is abstract so of course you'll want to use one of the
'implementation'
> > > > classes).  Since
> > > > java.sql.Date extends java.util.Date you can of course use the
> > > > java.text.DateFormat classes
> > > > to format a java.sql.Date.
> > > >
> > > > Secondly, the problem you are having using java.sql.Date could be if
you
> > are
> > > > importing java.util.*.  This will import java.util.Date in addition
to
> > > > java.sql.Date.
> > > > Therefore, when you code Date d = new Date() the compiler doesn't
know
> > which
> > > > classdef
> > > > to use.  One solution to to not import anything using splay(*).
This is
> > the
> > > > way we
> > > > do it.  You import block may get a little large but it also makes it
> > easier
> > > > for other
> > > > developers to figure out where to look for source.  Another is to
code
> > it as
> > > > java.sql.Date d = new java.sql.Date();
> > > >
> > > > ---
> > > > Michael Wentzel
> > > > Software Developer
> > > > Software As We Think - http://www.aswethink.com
> > >
> > > --
> > > Cordialement,
> > >
> > >
> > > Stéphane BAUDET
> > >
> > > _________________________________________________________
> > > GL Trade
> > > 48, rue Notre Dame des Victoires - 75002 Paris
> > > Tel : 01 53 40 43 12 (interne 1312)
> > > Fax : 01 53 40 01 40
> > > Email : sbaudet@gltrade.fr
> > > _________________________________________________________
> >
>
> Milt Epstein
> Research Programmer
> Software/Systems Development Group
> Computing and Communications Services Office (CCSO)
> University of Illinois at Urbana-Champaign (UIUC)
> mepstein@uiuc.edu
>


Mime
View raw message