Re: Date: Can you have one that is just mm/dd or mm/yyyy etc?




"LibbyChantel" wrote...

"Thomas Weidenfeller" wrote...

"LibbyChantel" wrote...

Unfortunately, yes, I do.

No, you don't. You are mixing up the representation of a value,
and the value itself.

OK, you're right I don't.

I studied the API doc for SimpleDateFormat before
submitting my plea for help. I guess my real question
is, how do I know if a Date portion such as day is not
a valid value for my application, ie when Date = 01/05/2001,
how do I know to ignore the month portion (or day, or year)
because it is only a placeholder? If I try to create a Date
with 01/00/2001 or some such, I of course get an
unparseableDate exception.

I think you still need to think over what Thomas said; to realize that
there's a difference between a value and its representation.

A Date is internally represented by a long (number of milliseconds since
since January 1, 1970, 00:00:00 GMT), but as such it can only have values
that corresponds to valid times and dates. There's no way around that.

You actually provided half the answer to the solution yourself in a previous
post.

You want to format an SQL statement (which is represented by a *String*):

"LIKE %theMm/yyyyDate%"

....which means that what you put into that string should be a string itself.

In order to provide the *format* of that part of the string, you simply use
a SimpleDateFormat to format a valid Date into the String representation you
like, even excluding the day part.

That is what you want to put into your SQL statement, not the Date itself.

// Bjorn A



Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php
.



Relevant Pages

  • Re: FutureWarning
    ... Something has been lost in going to this format, ... of 'hex' to represent the abstract bit pattern of a two's complement representation of ... to prefix something to indicate how to interpret, like the old 0x prefix, but ... Perhaps there could be string formatting to match, e.g., ...
    (comp.lang.python)
  • Re: How to kill .NET perfomance easy :)
    ... I forgot about ToString method in .NET objects because I never ... A numeric format string. ... The string representation of the value of this instance as specified by ...
    (borland.public.delphi.non-technical)
  • Re: How to kill .NET perfomance easy :)
    ... Strings in .NET aren't reference counted, ... A numeric format string. ... The string representation of the value of this instance as specified by ...
    (borland.public.delphi.non-technical)
  • Re: SimpleDateFormat challenge
    ... I need to convert a timestamp value in a string (from a text file that I ... that I the format of the input string does not seem to ... I cannot find any pattern for SimpleDateFormat to parse the time portion ...
    (comp.lang.java.programmer)
  • Re: Date Formatting with Java
    ... getDateInstancereturns the a DateFormat for the standard date format ... for your locale. ... for ideas of what to put in the String sent to SimpleDateFormat. ...
    (comp.lang.java.programmer)