Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Entering date  & time from JTable cell

Posted on 2005-03-22
14
Medium Priority
?
406 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
  • 5
  • 3
  • 3
11 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month11 days, 4 hours left to enroll

572 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