2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.model
.common
;
12 import java
.util
.Calendar
;
14 import javax
.persistence
.Embeddable
;
15 import javax
.persistence
.Temporal
;
16 import javax
.persistence
.TemporalType
;
17 import javax
.persistence
.Transient
;
19 import org
.apache
.log4j
.Logger
;
24 * @created 08-Nov-2007 13:07:00
27 public class TimePeriod
implements Cloneable
{
28 private static final Logger logger
= Logger
.getLogger(TimePeriod
.class);
31 private Calendar start
;
39 public static TimePeriod
NewInstance(){
40 return new TimePeriod();
48 public static TimePeriod
NewInstance(Calendar startDate
){
49 return new TimePeriod(startDate
);
57 public static TimePeriod
NewInstance(Calendar startDate
, Calendar endDate
){
58 return new TimePeriod(startDate
, endDate
);
64 protected TimePeriod() {
67 public TimePeriod(Calendar startDate
) {
70 public TimePeriod(Calendar startDate
, Calendar endDate
) {
75 @Temporal(TemporalType
.TIMESTAMP
)
76 public Calendar
getStart() {
79 public void setStart(Calendar start
) {
83 @Temporal(TemporalType
.TIMESTAMP
)
84 public Calendar
getEnd() {
87 public void setEnd(Calendar end
) {
92 public String
getYear(){
95 result
+= String
.valueOf(this.start
.get(Calendar
.YEAR
));
97 result
+= "-" + String
.valueOf(this.end
.get(Calendar
.YEAR
));
101 result
+= String
.valueOf(this.end
.get(Calendar
.YEAR
));
108 //*********** CLONE **********************************/
111 * @see java.lang.Object#clone()
114 public TimePeriod
clone() {
116 TimePeriod result
= (TimePeriod
)super.clone();
117 result
.setStart((Calendar
)start
.clone());
118 result
.setEnd((Calendar
)start
.clone());
120 } catch (CloneNotSupportedException e
) {
121 logger
.warn("Clone not supported exception. Should never occurr !!");