?
Solved

Entering date  & time from JTable cell

Posted on 2005-03-22
14
Medium Priority
?
396 Views
Last Modified: 2012-08-13
Hi,
i would like to force the user to enter a String in a given time and date format so that it is properly parsed into my MS Access database where the column type are date/time.
In what format should the string entered in JTable cells and how should i parse it into db.
0
Comment
Question by:komlaaa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
14 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 800 total points
ID: 13606550
That's tricky without using a special component. You could use this one:

http://www.toedter.com/en/jcalendar/
0
 

Author Comment

by:komlaaa
ID: 13606718
but what about time, i have some of my database column which are just time.
Also, if i decide to do it this way, i will have to use beans correct?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13606733
I think that component handles time too
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 92

Assisted Solution

by:objects
objects earned 800 total points
ID: 13608582
> http://www.toedter.com/en/jcalendar/

How would you use that exactly??
(Have you ever actually used it)
0
 
LVL 92

Expert Comment

by:objects
ID: 13608594
You should use a JFormattedTextFiled as your table cell editor
Here's an example of its use:
http://javaalmanac.com/egs/javax.swing.text/formtext_FormTextDate.html

the following discusses custom table cell editors:
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#validtext

Might also have a look at this one:
http://www.programurl.com/mistygrid.htm
0
 

Author Comment

by:komlaaa
ID: 13618330
>>How would you use that exactly??
as you could see on this page: http://people.clarkson.edu/~havenssm/gui4.doc
the user should be able to enter a date and time and save it to database in correct format for later retrieval.
 On Exams Panel, Total Time = Time out - Time in, so i couldn't just user String because i would the program to that the math  when the user press save button, (or better as soon as the cursor leave time out cell Total cell should be updated automatically.)
0
 
LVL 92

Expert Comment

by:objects
ID: 13618353
Theres an example here that shows doing totals

http://www.objects.com.au/java/examples/swing/TableTotalRow.do
0
 

Author Comment

by:komlaaa
ID: 13618852
>Theres an example here that shows doing totals
that will help in calculating the total, but my other problem is:
in database, i have time and date in format mm/dd/yyyy/ and tt:mm but when i display them on JTable, the format got
disturbed as you can see here:http://people.clarkson.edu/~havenssm/gui4.doc
0
 
LVL 92

Expert Comment

by:objects
ID: 13618877
you can use a custom cell renderer to format the cell however u require.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13620003
>>How would you use that exactly??

As a custom cell renderer

>>(Have you ever actually used it)

How is that relevant?
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month14 days, 4 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question