TimeSeriesCharts with compatible XYDataset number for X-Date

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
luna82
Posts: 5
Joined: Tue Jun 27, 2006 11:11 am

TimeSeriesCharts with compatible XYDataset number for X-Date

Post by luna82 » Tue Jul 11, 2006 3:22 pm

Hello, I use a TimeSeriesCharts with 5 TimeSeries.

The y axis is okay. But the Time and the Date make problems.

Incoming is a long number "20050101153010" that meens "yyyymmddhhmmss"

My Dataset:

Code: Select all

private XYDataset createDatasetFromFile(){
			final XYSeries seriesVmin = new XYSeries("VMin");
			final XYSeries seriesVmax = new XYSeries("EVax");
			//....

			seriesVmin.add(20050101153000, 1);
			seriesVmin.add(20050101160000, 2);
			seriesVmin.add(20050101163000, 3);
			seriesVmin.add(20050101170000, 4);

			//..
}
How can I display a good normal Time oder Date in the x axis?

Now I see only 01:00:10.000. I don't know what I do wrong.

How can I convert the "yyyymmddhhmmss" number to a compatible cfreechart number.
I read about the 01-01-1970, but I don't under stand it :roll:

Best Regards
Luna82

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Post by skunk » Tue Jul 11, 2006 3:43 pm

Something like this perhaps?

Code: Select all

DateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmss");
Date dte = fmt.parse(....);
double val = (double)dte.getTime();

luna82
Posts: 5
Joined: Tue Jun 27, 2006 11:11 am

Post by luna82 » Wed Jul 12, 2006 11:37 am

THX, it is running with the parse error exception :D

Code: Select all

					    		 try {
						   		      DateFormat fmt1 = new SimpleDateFormat("yyyyMMddHHmmss"); 
						   		      java.util.Date dte = new java.util.Date();
						   		      dte = fmt1.parse(datumzeit);   //datumzeit = "20050505121212"
						   		      long val = dte.getTime();
						   		      zeitstempel = val; //Unix Time Stamp
						   		  }
					   		      catch (java.text.ParseException pe) {

					   		    	System.out.println("ERROR please call your admin");
					   		    	
					   		      }

Best Regards
Luna

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Wed Jul 12, 2006 3:09 pm

The conversion works for me, but I think the characters you pass to SimpleDateFormat are locale specific, so maybe that is the problem for you.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked