add factory method to TimePeriod for Date
authorAndreas Müller <a.mueller@bgbm.org>
Wed, 5 Sep 2012 17:07:32 +0000 (17:07 +0000)
committerAndreas Müller <a.mueller@bgbm.org>
Wed, 5 Sep 2012 17:07:32 +0000 (17:07 +0000)
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/TimePeriod.java

index afbf8d9cc475c45fda4c242cfddc516a5e2676b7..1d42c4f28fd3ee683a83d850d654190449bf6178 100644 (file)
@@ -168,6 +168,18 @@ public class TimePeriod implements Cloneable, Serializable {
                }
                return new TimePeriod(startDate, endDate);
        }
+       
+       /**
+        * Factory method to create a TimePeriod from a starting and an ending <code>Date</code>   
+        * @return TimePeriod
+        */
+       public static TimePeriod NewInstance(Date startDate, Date endDate){
+               Calendar calStart = Calendar.getInstance();
+               calStart.setTime(startDate);
+               Calendar calEnd = Calendar.getInstance();
+               calEnd.setTime(endDate);
+               return NewInstance(calStart, calEnd);
+       }
 
        
        /**