Results 1 to 3 of 3
- 03-31-2009, 06:20 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 7
- Rep Power
- 0
how select date form calendar to textFeild
hi
i want customer choose departure date from calendar the it displayed in textfeild .
i do this
pls inform me
//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);
thanks
- 04-04-2009, 11:29 AM #2
Member
- Join Date
- Mar 2009
- Posts
- 20
- Rep Power
- 0
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:
Sun's web site can tell you how to create a format string to display a date and time the way you want it.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()));
- 04-04-2009, 12:16 PM #3
Similar Threads
-
How to retain value in struts 2 using <s:select></s:select> tag
By SaiPrasad@Sella in forum Web FrameworksReplies: 0Last Post: 02-09-2009, 07:23 AM -
Compare date input to database with current date
By hungleon88 in forum Advanced JavaReplies: 2Last Post: 11-25-2008, 08:10 AM -
Creating a Gregorian Calendar using a Date object gives date - 1
By prachi_goliwadekar in forum New To JavaReplies: 1Last Post: 05-08-2008, 08:32 PM -
java Date and Calendar
By valoyivd in forum New To JavaReplies: 1Last Post: 03-30-2008, 06:49 PM -
Calendar.DATE
By mew in forum New To JavaReplies: 1Last Post: 01-04-2008, 07:51 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks