[jboss-cvs] JBossAS SVN: r104380 - projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Apr 30 14:16:57 EDT 2010
Author: marius.bogoevici
Date: 2010-04-30 14:16:56 -0400 (Fri, 30 Apr 2010)
New Revision: 104380
Modified:
projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/Account.java
projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/TimeInterval.java
Log:
adjust handling of intervals
Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/Account.java
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/Account.java 2010-04-30 18:06:46 UTC (rev 104379)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/Account.java 2010-04-30 18:16:56 UTC (rev 104380)
@@ -1,13 +1,20 @@
package org.jboss.snowdrop.samples.sportsclub.domain.entity;
-import javax.persistence.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
-import java.util.TimeZone;
+import javax.persistence.CascadeType;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToOne;
+
import org.jboss.snowdrop.samples.sportsclub.utils.DateUtils;
/**
@@ -36,8 +43,6 @@
private boolean closed;
private Date closeDate;
- private static final TimeZone TIME_ZONE = TimeZone.getTimeZone("EST");
- private static final long TWO_WEEKS = (14 * 24 * 3600 * 1000);
public Account()
@@ -79,13 +84,13 @@
public void setCreationDate(Date creationDate)
{
- this.creationDate = DateUtils.normalizeDate(creationDate, TIME_ZONE);
+ this.creationDate = DateUtils.normalizeDate(creationDate, TimeInterval.TIME_ZONE);
}
public TimeInterval getBillingPeriodFor(Date date)
{
- Date normalizedDate = DateUtils.normalizeDate(date, TIME_ZONE);
- Calendar calendar = new GregorianCalendar(TIME_ZONE);
+ Date normalizedDate = DateUtils.normalizeDate(date, TimeInterval.TIME_ZONE);
+ Calendar calendar = new GregorianCalendar(TimeInterval.TIME_ZONE);
calendar.setTime(normalizedDate);
TimeInterval timeInterval = new TimeInterval();
switch (billingType)
@@ -104,7 +109,7 @@
break;
case BIWEEKLY:
long duration = normalizedDate.getTime() - getCreationDate().getTime();
- long intervals = duration / TWO_WEEKS;
+ long intervals = duration / TimeInterval.TWO_WEEKS;
calendar.setTime(getCreationDate());
calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
calendar.add(Calendar.DAY_OF_MONTH, (int)intervals * 14);
@@ -145,7 +150,7 @@
public void setCloseDate(Date closeDate)
{
- this.closeDate = DateUtils.normalizeDate(closeDate, TIME_ZONE);
+ this.closeDate = DateUtils.normalizeDate(closeDate, TimeInterval.TIME_ZONE);
}
public BigDecimal getFeePerBillingPeriod()
Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/TimeInterval.java
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/TimeInterval.java 2010-04-30 18:06:46 UTC (rev 104379)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/TimeInterval.java 2010-04-30 18:16:56 UTC (rev 104380)
@@ -1,18 +1,27 @@
package org.jboss.snowdrop.samples.sportsclub.domain.entity;
-import javax.persistence.Embeddable;
import java.util.Date;
+import java.util.TimeZone;
+import javax.persistence.Embeddable;
+
+import org.jboss.snowdrop.samples.sportsclub.utils.DateUtils;
+
/**
* @author Marius Bogoevici
*/
@Embeddable
public class TimeInterval
{
+ public static final TimeZone TIME_ZONE = TimeZone.getTimeZone("EST");
+
+ public static final long TWO_WEEKS = (14 * 24 * 3600 * 1000);
+
private Date startDate;
private Date endDate;
+
public Date getEndDate()
{
return endDate;
@@ -20,7 +29,7 @@
public void setEndDate(Date endDate)
{
- this.endDate = endDate;
+ this.endDate = DateUtils.normalizeDate(endDate,TIME_ZONE);
}
public Date getStartDate()
@@ -30,11 +39,12 @@
public void setStartDate(Date startDate)
{
- this.startDate = startDate;
+ this.startDate = DateUtils.normalizeDate(startDate,TIME_ZONE);
}
public boolean contains(Date someDate)
{
- return someDate.compareTo(startDate) >= 0 && someDate.compareTo(endDate)<=0;
+ Date normalizeDate = DateUtils.normalizeDate(someDate,TIME_ZONE);
+ return normalizeDate.compareTo(startDate) >= 0 && normalizeDate.compareTo(endDate)<=0;
}
}
More information about the jboss-cvs-commits
mailing list