× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thanks for the info.

I should probably mention that I don't know if BeanUtils.copyProperties will 
copy a string to a sql.Date correctly or not.  I'm having problem with the 
String to Date converstion ==> have put it in my jsp yet.  I wonder if anybody 
know for sure if that will work.  If not how do I go around this.

-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx]On Behalf Of Igor Seremet
Sent: Tuesday, February 01, 2005 10:08 AM
To: Java Programming on and around the iSeries / AS400
Subject: Re: How To: String --> sql.Date and String --> java.util.Date


I am not familiar with the tools that you're using, but I know that
java uses introspection to discover javabeans' properties, which means
that it would look at the return value of the 'set' methods and
determine the return type -- perhaps this is how it knows how to map
it!

If you don't need hh:mm:ss, you can set a different parse-string using
the following:

 Symbol   Meaning                 Presentation        Example
 ------   -------                 ------------        -------
 G        era designator          (Text)              AD
 y        year                    (Number)            1996
 M        month in year           (Text & Number)     July & 07
 d        day in month            (Number)            10
 h        hour in am/pm (1~12)    (Number)            12
 H        hour in day (0~23)      (Number)            0
 m        minute in hour          (Number)            30
 s        second in minute        (Number)            55
 S        millisecond             (Number)            978
 E        day in week             (Text)              Tuesday
 D        day in year             (Number)            189
 F        day of week in month    (Number)            2 (2nd Wed in July)
 w        week in year            (Number)            27
 W        week in month           (Number)            2
 a        am/pm marker            (Text)              PM
 k        hour in day (1~24)      (Number)            24
 K        hour in am/pm (0~11)    (Number)            0
 z        time zone               (Text)              Pacific Standard Time
 '        escape for text         (Delimiter)
 ''       single quote            (Literal)           '


These are specified in the API for java.text.SimpleDateFormat

Igor


On Tue, 1 Feb 2005 09:27:48 -0600, Lim Hock-Chai
<Lim.Hock-Chai@xxxxxxxxxxxxxxx> wrote:
> thanks for the sample codes.  My date string doesn't contains hh:mm:ss.  I 
> think I probably know how to get around that if Date class error it out.
> 
> Got another question:
> I use Apache's BeanUtils.copyProperties copy bean properties from ActionForm 
> to my DAO class.  In the ActionForm the date is string but in the DAO the 
> date is sql.Date.  How does BeanUtils.copyProperties knows how to copy it 
> correctly?
> 
> -----Original Message-----
> From: java400-l-bounces@xxxxxxxxxxxx
> [mailto:java400-l-bounces@xxxxxxxxxxxx]On Behalf Of Igor Seremet
> Sent: Tuesday, February 01, 2005 9:02 AM
> To: Java Programming on and around the iSeries / AS400
> Subject: Re: How To: String --> sql.Date and String --> java.util.Date
> 
> 1)
>  /**
>   * Check if the specified timestamp is greater than now
>   *
>   * @param futureTimestamp
>   * @return
>   */
>  public static boolean isValid(Timestamp futureTimestamp) {
>    if (futureTimestamp != null) {
>      Timestamp now = new Timestamp(System.currentTimeMillis());
>      return futureTimestamp.after(now);
>    }
>    else {
>      return false;
>    }
>  }
> 
> 2)
> 
>  public static java.sql.Date toDate(String strDate)
>      throws NullPointerException {
>    if (strDate == null) {
>      throw new NullPointerException("Date invalid.");
>    }
>    else {
>      java.sql.Date parsedDate = null;
>      try {
>        SimpleDateFormat formatter = new
> SimpleDateFormat("yyyy-mm-dd-hh.mm.ss");
>        parsedDate = new Date(formatter.parse(strDate).getTime());
> 
>      }
>      catch (Exception e) {
>        e.printStackTrace();
>      }
>      return parsedDate;
>    }
>  }
> 
> 
> --
> This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) 
> mailing list
> To post a message email: JAVA400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/java400-l
> or email: JAVA400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/java400-l.
> 
>
-- 
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) 
mailing list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.