Hi Yoel,
At the moment my code looks like the following:
TimeZone gmt = TimeZone .getDefault();
GregorianCalendar inauguration = new GregorianCalendar(gmt);
SimpleDateFormat sdf = new SimpleDateFormat( "EEE dd/MM/yyyy hh:mm:ss aa " );
sdf.setCalendar(inauguration );
String theDate = sdf.format(inauguration .getTime());
try
{
// set timestamp
Date date = sdf.parse (theDate);
inauguration.setTime(date );
java.sql.Date sdate = new java.sql.Date(date.getTime());
PreparedStatement ps = connection.prepareStatement("INSERT INTO
test " +
"VALUES (?)");
ps.setDate(1,sdate);
ps.executeUpdate();
ps.close();
As seen above I can format a java.util.date and insert into a text based cell in a table. I can also create a SQL date nad insert that into a date type cell, but its just the formatting.
How would your code work with mine ?
Suhail.
Originally posted by yoel stern:
Hi Suhail,
its very simple, this is how I do it:
StringTokenizer tokens = new StringTokenizer( res.getDate(c++).toString(), "-" );
String year = tokens.nextToken();
String month = tokens.nextToken();
String day = tokens.nextToken();
String d = month + "/" + day + "/" + year;
now you could just write, myJTextField.setText( d );
hope this will be some help, tell me if it helped you.
Yoel