| Author |
String to date problem
|
Tim Nachreiner
Greenhorn
Joined: Apr 28, 2011
Posts: 8
|
|
I have this class:
I can't figure out how to stuff a date from a JTextfield into this element.
How to I convert date to a date compatible with java.sql.Date?
The larger question is whether passwordChangeDate has the correct data type. Maybe it should have been java.util.Date? I am storing this info in a database. What is the standard way of datatyping date elements that are stored in a database?
|
 |
Jeff Verdegan
Bartender
Joined: Jan 03, 2004
Posts: 3144
|
|
So you have an object of one class (call it "A") and you need an object of a different class ("B")? Then you need to look at the ways that exist to create a B object, and then see what you might do with your A object to provide the information needed. (This technique is of general use, not just with dates, hence "A" and "B".)
In the simplest case, java.sql.Date would have a constructor that takes a java.util.Date as an arg. It doesn't however (and I have no idea why not--seems like a stupid design choice to me), but it does have another constructor that you can use.
And Welcome to the Ranch!
|
 |
 |
|
|
subject: String to date problem
|
|
|