|
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; } } On Tue, 01 Feb 2005 15:38:37 +0100, Franco Biaggi <fbiaggi@xxxxxxxxxx> wrote: > You may look at java.text.SimpleDateFormat > > Lim Hock-Chai wrote: > > >I posted below to java101 group and got no respond. Thought I try it here. > > > > > > > >I've a jsp that contains a text input field that represent a date. This date > >is map to a Date field in a table. > > > >I'm using Struts to control the application flow. When user press submit, > >the ActionForm takes over and basically call the Validate Action class and > >Form Action that uses beancopy to copy data to a DAO class. In this DAO > >class, I declare the date field as sql.Date. > > > >Can somebody show me how should I handle the following: > > > >1) In the Validation action, I need to check the input Date field (String > >class) to make sure that it is greater than today's date. How should I do > >this? > > > >2) In the bean copy or my DAO, how should I convert this String to sql.Date? > > > >Thanks. > > > > > > > > -- > ----------------------------------------------------------------------------- > *** This messages was scanned for malicious contents *** > ----------------------------------------------------------------------------- > Franco Biaggi > CH-6807 Taverne > > > -- > 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 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.