Hi,
I need to display a time in the x-axis. The format should be HH:mm:ss.
My data is the number of seconds for x and a value for y. Instead of displaying the number of seconds I need to display a time in the format HH:mm:ss.
How can I do that?
Jan
How to display time in X-axis
Code: Select all
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
Date d = new Date(time);
Second sec = getSecond(sdf.format(d));
series.add(sec, value);
Code: Select all
protected static Second getSecond( String sec )
{
try
{
CSVTokenizer ct = new CSVTokenizer (sec, ":");
//get hour
int hour = Integer.parseInt(ct.nextToken() );
//get minute
int min = Integer.parseInt(ct.nextToken() );
//get seconds
int secs = Integer.parseInt(ct.nextToken() );
//#TODO Use current day, month and year of timestamp
return new Second (secs, min, hour, 1, 1, 2005);
}
catch ( Exception e )
{
e.printStackTrace();
}
return null;
}//end getsec