summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpshi2011-11-28 05:06:17 (EST)
committer mwu2011-11-28 05:06:17 (EST)
commit7cfb1635ed39ca737e7f69f67a8f3e884b4b1f93 (patch)
tree73428c57527482a06724c05879162f7e1372223f
parentba0b85774a2e613ca31829d3545cd1278e7bec89 (diff)
downloadorg.eclipse.birt-7cfb1635ed39ca737e7f69f67a8f3e884b4b1f93.zip
org.eclipse.birt-7cfb1635ed39ca737e7f69f67a8f3e884b4b1f93.tar.gz
org.eclipse.birt-7cfb1635ed39ca737e7f69f67a8f3e884b4b1f93.tar.bz2
fix a bug when set the calendar.week
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TimeMemberUtil.java26
1 files changed, 24 insertions, 2 deletions
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TimeMemberUtil.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TimeMemberUtil.java
index e45c7b8..e09d8b3 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TimeMemberUtil.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TimeMemberUtil.java
@@ -66,6 +66,8 @@ public class TimeMemberUtil
}
int[] levelValue = new int[levelType.length];
Calendar cal = getCalendar( referenceDate );
+ int year_woy = 1;
+ int year = 1;
for( int i = 0; i < cellTimeMember.getLevelType().length; i++)
{
if( TimeMember.TIME_LEVEL_TYPE_YEAR.equals( cellTimeMember.getLevelType()[i] ) )
@@ -95,11 +97,31 @@ public class TimeMemberUtil
}
else if( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_YEAR.equals( cellTimeMember.getLevelType()[i] ) )
{
- cal.set( Calendar.WEEK_OF_YEAR, cellTimeMember.getMemberValue()[i] );
+ year_woy = cal.get( Calendar.YEAR_WOY );
+ year = cal.get( Calendar.YEAR );
+ // year_woy < year, means last week of previous year
+ // for example. 2011/1/1, the year_woy is 2010
+ if ( year_woy < year )
+ {
+ cal.add( Calendar.DAY_OF_WEEK, 7 );
+ }
+ cal.set( Calendar.DAY_OF_WEEK, 1 );
+ cal.set( Calendar.WEEK_OF_YEAR,
+ cellTimeMember.getMemberValue( )[i] );
}
else if( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH.equals( cellTimeMember.getLevelType()[i] ) )
{
- cal.set( Calendar.WEEK_OF_MONTH, cellTimeMember.getMemberValue()[i] );
+ year_woy = cal.get( Calendar.YEAR_WOY );
+ year = cal.get( Calendar.YEAR );
+ // year_woy < year, means last week of previous year
+ // for example. 2011/1/1, the year_woy is 2010
+ if ( year_woy < year )
+ {
+ cal.add( Calendar.DAY_OF_WEEK, 7 );
+ }
+ cal.set( Calendar.DAY_OF_WEEK, 1 );
+ cal.set( Calendar.WEEK_OF_MONTH,
+ cellTimeMember.getMemberValue( )[i] );
}
}
for( int i = 0; i < levelType.length; i++ )