|
Probably through the use of introspection. --- 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. > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
As an Amazon Associate we earn from qualifying purchases.
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.