How to use date in java?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: How to use date in java?

  1. #1
    Join Date
    Mar 2005
    Posts
    6

    Question How to use date in java?

    Hi,

    If I want a user to input a date alone, not with time, how can I do it? Eg. A customer calls to make a reservation at a restaurant, the user has to key in a date that the customer wants to reserve the place for.

    I can't use int cos validating data will be very troublesome right? Is it possible to show me an example? Furthermore, I need to store the date attribute in an object reservation and to later on implement a search function based on the date.

    Would really appreciate an example. Thanks so much..

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    Use the Calendar class for reading and set the allowed formats for the textfield that receives the date. Then store the date in a java.sql.Date object
    for use in databases.
    Last edited by sjalle; 03-24-2005 at 09:41 PM.
    eschew obfuscation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center