|
From: <nic...@us...> - 2003-09-02 11:33:09
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/scratchpad/org/krysalis/jcharts/gantt
In directory sc8-pr-cvs1:/tmp/cvs-serv2691/src/scratchpad/org/krysalis/jcharts/gantt
Modified Files:
DateHandler.java
Log Message:
Fix getStringDateFromWeek
Index: DateHandler.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/scratchpad/org/krysalis/jcharts/gantt/DateHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DateHandler.java 2 Sep 2003 10:32:51 -0000 1.4
--- DateHandler.java 2 Sep 2003 11:33:05 -0000 1.5
***************
*** 48,56 ****
**/
public class DateHandler {
!
! private final static DateFormat shortFormat = DateFormat.getDateInstance(DateFormat.SHORT);
! private final static DateFormat monthFormat = new SimpleDateFormat("MMMMM");
! private final static DateFormat dayMonthFormat= new SimpleDateFormat("dd/MM");
! private final static DateFormat dateStampFormat= new SimpleDateFormat("yyyyMMdd");
private Date currentDay;
--- 48,59 ----
**/
public class DateHandler {
!
! private final static DateFormat shortFormat =
! DateFormat.getDateInstance(DateFormat.SHORT);
! private final static DateFormat monthFormat = new SimpleDateFormat("MMMMM");
! private final static DateFormat dayMonthFormat =
! new SimpleDateFormat("dd/MM");
! private final static DateFormat dateStampFormat =
! new SimpleDateFormat("yyyyMMdd");
private Date currentDay;
***************
*** 65,69 ****
public DateHandler(Date startDate, Date endDate) {
!
//calculate the date
this.currentDay = cleanDay(new Date());
--- 68,72 ----
public DateHandler(Date startDate, Date endDate) {
!
//calculate the date
this.currentDay = cleanDay(new Date());
***************
*** 73,83 ****
cal = Calendar.getInstance();
! // if (lastWeek == null || future == null) {
! // int dow = cal.get(Calendar.DAY_OF_WEEK);
! // cal.add(Calendar.DATE, -dow - 6);
! // lastWeek = cleanDay(cal.getTime());
! // cal.add(Calendar.DATE, 5 * 7);
! // future = cleanDay(cal.getTime());
! // }
totalDays = (long) getDayDiff(future, lastWeek);
--- 76,86 ----
cal = Calendar.getInstance();
! // if (lastWeek == null || future == null) {
! // int dow = cal.get(Calendar.DAY_OF_WEEK);
! // cal.add(Calendar.DATE, -dow - 6);
! // lastWeek = cleanDay(cal.getTime());
! // cal.add(Calendar.DATE, 5 * 7);
! // future = cleanDay(cal.getTime());
! // }
totalDays = (long) getDayDiff(future, lastWeek);
***************
*** 87,91 ****
shortFormat.format(currentDay);
}
!
public String format(Date d) {
return shortFormat.format(d);
--- 90,94 ----
shortFormat.format(currentDay);
}
!
public String format(Date d) {
return shortFormat.format(d);
***************
*** 154,167 ****
}
}
!
public int getDayDiff(Date start, Date end) {
return (int)
! ((cleanDay(start).getTime()
! - cleanDay(end).getTime()
! + 43200000)
/ 86400000);
}
-
public static Date getDate(String label) {
Calendar cal = Calendar.getInstance();
--- 157,167 ----
}
}
!
public int getDayDiff(Date start, Date end) {
return (int)
! ((cleanDay(start).getTime() - cleanDay(end).getTime() + 43200000)
/ 86400000);
}
public static Date getDate(String label) {
Calendar cal = Calendar.getInstance();
***************
*** 179,188 ****
intVal = Integer.valueOf(str).intValue();
cal.set(Calendar.DATE, intVal);
!
! cal.set(Calendar.HOUR, 0);
! cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
!
return cal.getTime();
}
--- 179,188 ----
intVal = Integer.valueOf(str).intValue();
cal.set(Calendar.DATE, intVal);
!
! cal.set(Calendar.HOUR, 0);
! cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
!
return cal.getTime();
}
***************
*** 218,222 ****
c.set(Calendar.WEEK_OF_YEAR, week);
if (startDay) {
! c.roll(Calendar.DATE, -4);
}
--- 218,225 ----
c.set(Calendar.WEEK_OF_YEAR, week);
if (startDay) {
! c.roll(Calendar.DATE, -1);
! }
! else {
! c.roll(Calendar.DATE, 3);
}
***************
*** 228,240 ****
// return resultYear+resultMonth+resultDay;
-
Date result = c.getTime();
!
return dateStampFormat.format(result);
}
!
!
// Private helper methods
!
private static Date cleanDay(long date) {
return DateHandler.cleanDay(new Date(date));
--- 231,241 ----
// return resultYear+resultMonth+resultDay;
Date result = c.getTime();
!
return dateStampFormat.format(result);
}
!
// Private helper methods
!
private static Date cleanDay(long date) {
return DateHandler.cleanDay(new Date(date));
***************
*** 251,255 ****
return date;
}
!
private static Date parseDate(String date) throws ParseException {
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
--- 252,256 ----
return date;
}
!
private static Date parseDate(String date) throws ParseException {
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
***************
*** 261,265 ****
return formatter.format(date);
}
-
}
--- 262,265 ----
|