Re: Validating Data in Java
This is a very simple code and I think this will help you
Code:
public void main (String args []) (
CalTester CalTester tst = new ();
ytt int = 2001;
mtt int = 10;
dtt int = 18;
tst.testDate (ytt, mtt, dtt);
ytt = 2001;
mtt = 14;
dtt = 18;
tst.testDate (ytt, mtt, dtt);
ytt = -2001;
mtt = 7;
dtt = 21;
tst.testDate (ytt, mtt, dtt);
ytt = 2001;
mtt = 158;
dtt = 21;
tst.testDate (ytt, mtt, dtt);
Re: Validating Data in Java
Here is another code which may help you
Code:
try
(
dtgeocal = new GregorianCalendar (year, nm - 1 day) / / 0 = January
dtgeocal.setLenient boundary (false) / / without this line, no possible exception
an dtgeocal.get int = (GregorianCalendar.YEAR);
nmb dtgeocal.get int = (GregorianCalendar.MONTH);
jrb dtgeocal.get int = (GregorianCalendar.DAY_OF_MONTH);
)
catch (Exception e)
(
e.printStackTrace ();
)
Re: Validating Data in Java
I want to get a date with a JTextField and save it in a MySQL database. I can add but the date is October 15, 1580, even if I put another date. for example code for this date is October 15, 1580, (c d2 and if I record in my database). How am I to insert a date of birth for any customer?
Re: Validating Data in Java
But when you say that you want to record in your database is to be recovered in a JTextField. What form is coming then? What format do you want to send? You have to have a way to send it to your base without or by date or by non Calendar, by doing a get of JTextField, and placing it in the desired shape before the transfer.
Re: Validating Data in Java
To enter a date specific (date of birth mentioned in your example, February 13, 1987):
use it as
Calendar c = new GregorianCalendar (int year, int month -1, int day);
either:
Calendar c = new GregorianCalendar (1987, 1, 13);