I've a problem with the dates.
I've an access database and one of its fields is defined as date/hour.
I've built a table and my problem is that only displays date and no hour.
I tried to implement the code following:
public Class getColumnClass(int c) {
if (c==1) return Minute.class;
if ((c==2)|(c==3)|(c==5)|(c==6)|(c==8)|(c==9)|(c==11)|(c==12))
return Integer.class;
return getValueAt(0,c).getClass();
}
but it doesnt't do well.
2003-03-30 01:50:00.0
2003-03-30 03:00:00.0 ¡It doesn't write 2003-03-30 02:00:00.0!
How can I solve it?
Thank's
PROBLEM with dates from database in a table
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
I don't understand the question.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Hello,
I' ve created a dataset from a DB access
public XYDataset createDataset(int min, int max) throws SQLException {
JDBCXYDataset data = null;
try
{
Driver d = (Driver)Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
}
catch (Exception e)
{
System.out.println(e);
}
// GET CONNECTION
Connection con = null;
try
{
String db = "BD";
String url = "jdbc:odbc:Practica;DBQ=" + db;
con = DriverManager.getConnection(url,"","");
data = new JDBCXYDataset(con);
String sql = "SELECT date,v1,v2 FROM a where (ID>="+ min+") and (ID<="+max+")";
data.executeQuery(sql);
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
this.series = new XYSeries("ana");
for (int i = 0; i < data.getItemCount(); i++) {
this.series.add(data.getXValue(0,i),data.getYValue(0,i));
}
return data;
}
data.getXValue(0,i) return double. Then how can I get the date of index i.
Thank's
I' ve created a dataset from a DB access
public XYDataset createDataset(int min, int max) throws SQLException {
JDBCXYDataset data = null;
try
{
Driver d = (Driver)Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
}
catch (Exception e)
{
System.out.println(e);
}
// GET CONNECTION
Connection con = null;
try
{
String db = "BD";
String url = "jdbc:odbc:Practica;DBQ=" + db;
con = DriverManager.getConnection(url,"","");
data = new JDBCXYDataset(con);
String sql = "SELECT date,v1,v2 FROM a where (ID>="+ min+") and (ID<="+max+")";
data.executeQuery(sql);
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
this.series = new XYSeries("ana");
for (int i = 0; i < data.getItemCount(); i++) {
this.series.add(data.getXValue(0,i),data.getYValue(0,i));
}
return data;
}
data.getXValue(0,i) return double. Then how can I get the date of index i.
Thank's
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
The double that it returns should be the number of milliseconds since 1-Jan-1970.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Hello, I found an strange behaviour
Calendar cal = new GregorianCalendar();
Calendar cal2 = new GregorianCalendar();
cal= new java.util.GregorianCalendar(2003,2,30,1,50,0) ;
cal2= new java.util.GregorianCalendar(2003,2,30,2,0,0) ;
System.out.println(new Minute(new Date(cal.getTimeInMillis())));
System.out.println(new Minute(new Date(cal2.getTimeInMillis())));
The result is:
Sun Mar 30 01:50:00 CET 2003
Sun Mar 30 03:00:00 CEST 2003 but it should be Sun Mar 02:00:00 2003
What is it happening?
Thank's
Calendar cal = new GregorianCalendar();
Calendar cal2 = new GregorianCalendar();
cal= new java.util.GregorianCalendar(2003,2,30,1,50,0) ;
cal2= new java.util.GregorianCalendar(2003,2,30,2,0,0) ;
System.out.println(new Minute(new Date(cal.getTimeInMillis())));
System.out.println(new Minute(new Date(cal2.getTimeInMillis())));
The result is:
Sun Mar 30 01:50:00 CET 2003
Sun Mar 30 03:00:00 CEST 2003 but it should be Sun Mar 02:00:00 2003
What is it happening?
Thank's