Results 1 to 3 of 3
  1. #1
    the swan is offline Member
    Join Date
    Mar 2009
    Posts
    7
    Rep Power
    0

    Default how select date form calendar to textFeild

    hi
    i want customer choose departure date from calendar the it displayed in textfeild .

    i do this




    //use getInstance() method to get object of java Calendar class
    Calendar cal = Calendar.getInstance();

    //use getTime() method of Calendar class to get date and time
    text1.getvalue=cal.get(Calendar.DATE);

    pls inform me
    thanks

  2. #2
    glhansen is offline Member
    Join Date
    Mar 2009
    Posts
    20
    Rep Power
    0

    Default

    If you want to get dates to and from text fields you should use a SimpleDateFormat, and it's probably better to just work with Date objects unless you need to do calculations, like adding so many days to a date. Example:

    Java Code:
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy");
    Date date = new Date();
    
    // Get text from field
    try {
      date = GUI.sdf.parse(myDateEntryField.getText());
    } catch (Exception e) {
      recoverFromDateEntryError();
    }
    
    // Put date in another field
    myBigDateDisplayField.setText(sdf.format(date));
    
    // Create a Calendar object with a date
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    
    // Get a date from a Calendar and put it in a text field
    myOtherTextField.setText(sdf.format(cal.getTime()));
    Sun's web site can tell you how to create a format string to display a date and time the way you want it.

  3. #3
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    441
    Rep Power
    6

    Default

    I think you want to use Calender control with your application ,is it?
    Mak
    (Living @ Virtual World)

Similar Threads

  1. How to retain value in struts 2 using <s:select></s:select> tag
    By SaiPrasad@Sella in forum Web Frameworks
    Replies: 0
    Last Post: 02-09-2009, 07:23 AM
  2. Compare date input to database with current date
    By hungleon88 in forum Advanced Java
    Replies: 2
    Last Post: 11-25-2008, 08:10 AM
  3. Creating a Gregorian Calendar using a Date object gives date - 1
    By prachi_goliwadekar in forum New To Java
    Replies: 1
    Last Post: 05-08-2008, 08:32 PM
  4. java Date and Calendar
    By valoyivd in forum New To Java
    Replies: 1
    Last Post: 03-30-2008, 06:49 PM
  5. Calendar.DATE
    By mew in forum New To Java
    Replies: 1
    Last Post: 01-04-2008, 07:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •