× 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 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;
    }
  }



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.