0

我正在尝试实现 Jfreechart API,但我遇到了问题:

这是我的代码

/**Adding data in this series**/
seriesOne.add(new Task("Project Progress Bar",
new SimpleTimePeriod(makeDate(25, Calendar.JUNE, 2013),
makeDate(30, Calendar.JUNE, 2013))));

/**adding second task**/
/**Adding data in this series**/
seriesTwo.add(new Task("Project Progress Bar",
new SimpleTimePeriod(makeDate(28, Calendar.JUNE, 2013),
makeDate(30, Calendar.JUNE, 2013))));

makeDate 方法

private static Date makeDate(final int day, final int month, final int year) {

final Calendar calendar = Calendar.getInstance();
calendar.set(year, month, day);
final Date result = calendar.getTime();
return result;

}

我需要传递d1="2011-03-06" d2="2011-05-06" d3="2011-05-06" d4="2011-05-06" 而不是对日期进行编码,我该怎么做

new SimpleTimePeriod(makeDate(d1),
  makeDate(d2))));

感谢任何帮助将不胜感激请

4

2 回答 2

1
//assuming dates are passed in as a string in the format "yyyy-MM-dd"

public Date makeDate(String date){
return new SimpleDateFormat("yyyy-MM-dd").parse(string);
}
于 2013-06-17T10:19:37.353 回答
0

使用 DateFormat 完成工作希望这有帮助??

Date d=DateFormat.getDateInstance(DateFormat.LONG).parse("June 13, 2013");
于 2013-06-17T10:19:36.353 回答