svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.timesupport / org.gvsig.timesupport.lib / org.gvsig.timesupport.lib.impl / src / main / java / org / gvsig / timesupport / impl / DefaultAbsoluteInterval.java @ 47282
History | View | Annotate | Download (19.3 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.timesupport.impl; |
23 |
|
24 |
import java.util.ArrayList; |
25 |
import java.util.List; |
26 |
|
27 |
import org.slf4j.Logger; |
28 |
import org.slf4j.LoggerFactory; |
29 |
|
30 |
import org.gvsig.timesupport.AbsoluteInstant; |
31 |
import org.gvsig.timesupport.AbsoluteInstantType; |
32 |
import org.gvsig.timesupport.AbsoluteInstantTypeNotRegisteredException; |
33 |
import org.gvsig.timesupport.AbsoluteInterval; |
34 |
import org.gvsig.timesupport.AbsoluteIntervalType; |
35 |
import org.gvsig.timesupport.AbsoluteIntervalTypeNotRegisteredException; |
36 |
import org.gvsig.timesupport.Chronology; |
37 |
import org.gvsig.timesupport.Duration; |
38 |
import org.gvsig.timesupport.Instant; |
39 |
import org.gvsig.timesupport.RelativeInstant; |
40 |
import org.gvsig.timesupport.Time; |
41 |
import org.gvsig.timesupport.TimeSupportLocator; |
42 |
import org.gvsig.timesupport.TimeSupportManager; |
43 |
|
44 |
/**
|
45 |
* @author gvSIG team
|
46 |
* @version $Id$
|
47 |
*/
|
48 |
public class DefaultAbsoluteInterval implements AbsoluteInterval{ |
49 |
static final long MILLIS_BY_SECOND = 1000; |
50 |
static final long MILLIS_BY_MINUTE = MILLIS_BY_SECOND * 60; |
51 |
static final long MILLIS_BY_HOUR = MILLIS_BY_MINUTE * 60; |
52 |
static final long MILLIS_BY_DAY = MILLIS_BY_HOUR * 24; |
53 |
static final long MILLIS_BY_MONTH = MILLIS_BY_DAY * 30; |
54 |
static final long MILLIS_BY_YEAR = MILLIS_BY_MONTH * 365; |
55 |
|
56 |
private static Logger LOG = LoggerFactory.getLogger(DefaultAbsoluteInterval.class); |
57 |
|
58 |
private org.joda.time.Period jodaPeriod = null; |
59 |
private AbsoluteInstant startAbsoluteInstant = null; |
60 |
private AbsoluteInstant endAbsoluteInstant = null; |
61 |
private AbsoluteIntervalType[] absoluteIntervalTypes = null; |
62 |
private Chronology chronology = null; |
63 |
|
64 |
private static final TimeSupportManager timeSupportManager = TimeSupportLocator.getManager(); |
65 |
|
66 |
DefaultAbsoluteInterval(AbsoluteInstant startPartial, int years, int months, int weeks, int days, |
67 |
int hours, int minutes, int seconds, int millis, Chronology chronology) throws AbsoluteIntervalTypeNotRegisteredException{ |
68 |
this(years, months, weeks, days, hours, minutes, seconds, millis, chronology);
|
69 |
initilizePartials(((DefaultAbsoluteInstant)startPartial).getJodaType()); |
70 |
} |
71 |
|
72 |
DefaultAbsoluteInterval(int years, int months, int weeks, int days, |
73 |
int hours, int minutes, int seconds, int millis, Chronology chronology) throws AbsoluteIntervalTypeNotRegisteredException{ |
74 |
super();
|
75 |
this.jodaPeriod = new org.joda.time.Period(years, months, weeks, days, hours, minutes, seconds, millis); |
76 |
this.absoluteIntervalTypes = new AbsoluteIntervalType[8]; |
77 |
this.absoluteIntervalTypes[0] = timeSupportManager.getAbsoluteIntervalType(AbsoluteIntervalType.YEARS); |
78 |
this.absoluteIntervalTypes[1] = timeSupportManager.getAbsoluteIntervalType(AbsoluteIntervalType.MONTHS); |
79 |
this.absoluteIntervalTypes[2] = timeSupportManager.getAbsoluteIntervalType(AbsoluteIntervalType.WEEKS); |
80 |
this.absoluteIntervalTypes[3] = timeSupportManager.getAbsoluteIntervalType(AbsoluteIntervalType.DAYS); |
81 |
this.absoluteIntervalTypes[4] = timeSupportManager.getAbsoluteIntervalType(AbsoluteIntervalType.HOURS); |
82 |
this.absoluteIntervalTypes[5] = timeSupportManager.getAbsoluteIntervalType(AbsoluteIntervalType.MINUTES); |
83 |
this.absoluteIntervalTypes[6] = timeSupportManager.getAbsoluteIntervalType(AbsoluteIntervalType.SECONDS); |
84 |
this.absoluteIntervalTypes[7] = timeSupportManager.getAbsoluteIntervalType(AbsoluteIntervalType.MILLIS); |
85 |
this.chronology = chronology;
|
86 |
initilizePartials(); |
87 |
} |
88 |
|
89 |
DefaultAbsoluteInterval(AbsoluteInstant startAbsoluteInstant, AbsoluteInstant endAbsoluteInstant, Chronology chronology) { |
90 |
super();
|
91 |
this.jodaPeriod = new org.joda.time.Period(startAbsoluteInstant.toStandardDuration().getMillis(), |
92 |
endAbsoluteInstant.toStandardDuration().getMillis()); |
93 |
this.chronology = chronology;
|
94 |
this.startAbsoluteInstant = startAbsoluteInstant;
|
95 |
this.endAbsoluteInstant = endAbsoluteInstant;
|
96 |
|
97 |
// int[] mergedTypes = mergeTypes(startAbsoluteInstant, endAbsoluteInstant);
|
98 |
// try {
|
99 |
// AbsoluteInstant startAbsoluteInstantAux = mergeTypes(mergedTypes, startAbsoluteInstant);
|
100 |
// AbsoluteInstant endAbsoluteInstantAux = mergeTypes(mergedTypes, endAbsoluteInstant);
|
101 |
// this.jodaPeriod = new org.joda.time.Period(((DefaultAbsoluteInstant)startAbsoluteInstantAux).getJodaType(),
|
102 |
// ((DefaultAbsoluteInstant)endAbsoluteInstantAux).getJodaType());
|
103 |
// this.chronology = chronology;
|
104 |
// this.startAbsoluteInstant = startAbsoluteInstantAux;
|
105 |
// this.endAbsoluteInstant = endAbsoluteInstantAux;
|
106 |
// } catch (AbsoluteInstantTypeNotRegisteredException e) {
|
107 |
// LOG.error("Error creating the interval");
|
108 |
// }
|
109 |
} |
110 |
|
111 |
// private AbsoluteInstant mergeTypes(int[] mergedTypes,
|
112 |
// AbsoluteInstant absoluteInstant) throws AbsoluteInstantTypeNotRegisteredException{
|
113 |
// int[] values = new int[mergedTypes.length];
|
114 |
// for (int i=0 ; i<mergedTypes.length ; i++){
|
115 |
// if (mergedTypes[i] == AbsoluteInstantType.YEAR){
|
116 |
// values[i] = absoluteInstant.getYears();
|
117 |
// }else if (mergedTypes[i] == AbsoluteInstantType.MONTH_OF_YEAR){
|
118 |
// values[i] = absoluteInstant.getMonths();
|
119 |
// if (values[i] == 0){
|
120 |
// values[i] = 1;
|
121 |
// }
|
122 |
// }else if (mergedTypes[i] == AbsoluteInstantType.DAY_OF_MONTH){
|
123 |
// values[i] = absoluteInstant.getDays();
|
124 |
// if (values[i] == 0){
|
125 |
// values[i] = 1;
|
126 |
// }
|
127 |
// }else if (mergedTypes[i] == AbsoluteInstantType.HOUR_OF_DAY){
|
128 |
// values[i] = absoluteInstant.getHours();
|
129 |
// }else if (mergedTypes[i] == AbsoluteInstantType.MINUTE_OF_HOUR){
|
130 |
// values[i] = absoluteInstant.getMinutes();
|
131 |
// }else if (mergedTypes[i] == AbsoluteInstantType.SECOND_OF_MINUTE){
|
132 |
// values[i] = absoluteInstant.getSeconds();
|
133 |
// }else if (mergedTypes[i] == AbsoluteInstantType.MILLIS_OF_SECOND){
|
134 |
// values[i] = absoluteInstant.getMillis();
|
135 |
// }else{
|
136 |
// values[i] = 0;
|
137 |
// }
|
138 |
// }
|
139 |
// return timeSupportManager.createAbsoluteInstant(mergedTypes, values, absoluteInstant.getChronology());
|
140 |
// }
|
141 |
//
|
142 |
// private int[] mergeTypes(AbsoluteInstant startAbsoluteInstant,
|
143 |
// AbsoluteInstant endAbsoluteInstant) {
|
144 |
// ArrayList types = new ArrayList();
|
145 |
// for (int i=0 ; i<startAbsoluteInstant.size() ; i++){
|
146 |
// types.add(startAbsoluteInstant.getFieldType(i).getType());
|
147 |
// }
|
148 |
//
|
149 |
// for (int i=0 ; i<endAbsoluteInstant.size() ; i++){
|
150 |
// int type = endAbsoluteInstant.getFieldType(i).getType();
|
151 |
// int position = -1;
|
152 |
// for (int j=0 ; j<types.size() ; j++){
|
153 |
// int addedType = (Integer)types.get(j);
|
154 |
// if (type < addedType){
|
155 |
// position = j;
|
156 |
// break;
|
157 |
// }else if (type == addedType){
|
158 |
// position = -2;
|
159 |
// }
|
160 |
// }
|
161 |
// if (position > -1){
|
162 |
// types.add(position, type);
|
163 |
// }else if (position == -1){
|
164 |
// types.add(type);
|
165 |
// }
|
166 |
// }
|
167 |
//
|
168 |
// int[] mergedTypes = new int[types.size()];
|
169 |
// for (int i=0 ; i<types.size() ; i++){
|
170 |
// mergedTypes[i] = (Integer)types.get(i);
|
171 |
// }
|
172 |
// return mergedTypes;
|
173 |
// }
|
174 |
|
175 |
DefaultAbsoluteInterval(RelativeInstant startPeriod, RelativeInstant endPeriod, Chronology chronology) { |
176 |
super();
|
177 |
this.jodaPeriod = new org.joda.time.Period(((DefaultRelativeInstant)startPeriod).getJodaType(), |
178 |
((DefaultRelativeInstant)endPeriod).getJodaType()); |
179 |
this.chronology = chronology;
|
180 |
initilizePartials(); |
181 |
} |
182 |
|
183 |
DefaultAbsoluteInterval(Chronology chronology, org.joda.time.Period period) { |
184 |
super();
|
185 |
this.jodaPeriod = period;
|
186 |
this.chronology = chronology;
|
187 |
initilizePartials(); |
188 |
} |
189 |
|
190 |
DefaultAbsoluteInterval(AbsoluteInstant startPartial, AbsoluteInstant endPartial) { |
191 |
super();
|
192 |
this.startAbsoluteInstant = startPartial;
|
193 |
this.endAbsoluteInstant = endPartial;
|
194 |
this.jodaPeriod = new org.joda.time.Period(endPartial.getYears() - startPartial.getYears(), |
195 |
0,
|
196 |
endPartial.getMonths() - startPartial.getMonths(), |
197 |
endPartial.getDays() - startPartial.getDays(), |
198 |
endPartial.getHours() - startPartial.getHours(), |
199 |
endPartial.getMinutes() - startPartial.getMinutes(), |
200 |
endPartial.getSeconds() - startPartial.getSeconds(), |
201 |
endPartial.getMillis() - startPartial.getMillis()); |
202 |
} |
203 |
|
204 |
@SuppressWarnings({"unchecked" }) |
205 |
private void initilizePartials(){ |
206 |
this.startAbsoluteInstant = new DefaultAbsoluteInstant(chronology); |
207 |
ArrayList types = new ArrayList(); |
208 |
ArrayList values = new ArrayList(); |
209 |
if (jodaPeriod.getYears() > 0){ |
210 |
types.add(AbsoluteInstantType.YEAR); |
211 |
values.add(jodaPeriod.getYears()); |
212 |
} |
213 |
if (jodaPeriod.getMonths() > 0){ |
214 |
types.add(AbsoluteInstantType.MONTH_OF_YEAR); |
215 |
values.add(jodaPeriod.getMonths()); |
216 |
} |
217 |
if (jodaPeriod.getWeeks() > 0){ |
218 |
types.add(AbsoluteInstantType.WEEK_OF_WEEKYEAR); |
219 |
values.add(jodaPeriod.getWeeks()); |
220 |
} |
221 |
if (jodaPeriod.getDays() > 0){ |
222 |
types.add(AbsoluteInstantType.DAY_OF_MONTH); |
223 |
values.add(jodaPeriod.getDays()); |
224 |
} |
225 |
if (jodaPeriod.getHours() > 0){ |
226 |
types.add(AbsoluteInstantType.HOUR_OF_DAY); |
227 |
values.add(jodaPeriod.getHours()); |
228 |
} |
229 |
if (jodaPeriod.getMinutes() > 0){ |
230 |
types.add(AbsoluteInstantType.MINUTE_OF_HOUR); |
231 |
values.add(jodaPeriod.getMinutes()); |
232 |
} |
233 |
if (jodaPeriod.getSeconds() > 0){ |
234 |
types.add(AbsoluteInstantType.SECOND_OF_MINUTE); |
235 |
values.add(jodaPeriod.getSeconds()); |
236 |
} |
237 |
if (jodaPeriod.getMillis() > 0){ |
238 |
types.add(AbsoluteInstantType.MILLIS_OF_SECOND); |
239 |
values.add(jodaPeriod.getMillis()); |
240 |
} |
241 |
int[] nativeTypes = new int[types.size()]; |
242 |
int[] nativeValues = new int[values.size()]; |
243 |
for (int i=0 ; i<types.size() ; i++){ |
244 |
nativeTypes[i] = (Integer)types.get(i);
|
245 |
nativeValues[i] = (Integer)values.get(i);
|
246 |
} |
247 |
try {
|
248 |
this.endAbsoluteInstant = timeSupportManager.createAbsoluteInstant(nativeTypes, nativeValues, chronology);
|
249 |
} catch (AbsoluteInstantTypeNotRegisteredException e) {
|
250 |
LOG.error("Impossible to create the endPartial for a period", e);
|
251 |
} |
252 |
} |
253 |
|
254 |
@SuppressWarnings({ "unchecked" }) |
255 |
private void initilizePartials(org.joda.time.Partial jodaPartial){ |
256 |
this.startAbsoluteInstant = new DefaultAbsoluteInstant(chronology, jodaPartial); |
257 |
org.joda.time.DateTimeFieldType[] dateTimeFieldTypes = jodaPartial.getFieldTypes();
|
258 |
int[] jodaValues = jodaPartial.getValues(); |
259 |
ArrayList types = new ArrayList(); |
260 |
ArrayList values = new ArrayList(); |
261 |
if (jodaPeriod.getYears() > 0){ |
262 |
types.add(AbsoluteInstantType.YEAR); |
263 |
values.add(jodaPeriod.getYears()); |
264 |
} |
265 |
if (jodaPeriod.getMonths() > 0){ |
266 |
types.add(AbsoluteInstantType.MONTH_OF_YEAR); |
267 |
values.add(jodaPeriod.getMonths()); |
268 |
} |
269 |
if (jodaPeriod.getDays() > 0){ |
270 |
types.add(AbsoluteInstantType.DAY_OF_MONTH); |
271 |
values.add(jodaPeriod.getDays()); |
272 |
} |
273 |
if (jodaPeriod.getHours() > 0){ |
274 |
types.add(AbsoluteInstantType.HOUR_OF_DAY); |
275 |
values.add(jodaPeriod.getHours()); |
276 |
} |
277 |
if (jodaPeriod.getMinutes() > 0){ |
278 |
types.add(AbsoluteInstantType.MINUTE_OF_HOUR); |
279 |
values.add(jodaPeriod.getMinutes()); |
280 |
} |
281 |
if (jodaPeriod.getSeconds() > 0){ |
282 |
types.add(AbsoluteInstantType.SECOND_OF_MINUTE); |
283 |
values.add(jodaPeriod.getSeconds()); |
284 |
} |
285 |
if (jodaPeriod.getMillis() > 0){ |
286 |
types.add(AbsoluteInstantType.MILLIS_OF_SECOND); |
287 |
values.add(jodaPeriod.getMillis()); |
288 |
} |
289 |
for (int i=0 ; i<dateTimeFieldTypes.length ; i++){ |
290 |
if (dateTimeFieldTypes[i].equals(org.joda.time.DateTimeFieldType.year())){
|
291 |
initializePartialsIteration(types, values, jodaValues[i], AbsoluteInstantType.YEAR); |
292 |
} else if (dateTimeFieldTypes[i].equals(org.joda.time.DateTimeFieldType.monthOfYear())){ |
293 |
initializePartialsIteration(types, values, jodaValues[i], AbsoluteInstantType.MONTH_OF_YEAR); |
294 |
} else if (dateTimeFieldTypes[i].equals(org.joda.time.DateTimeFieldType.dayOfMonth())){ |
295 |
initializePartialsIteration(types, values, jodaValues[i], AbsoluteInstantType.DAY_OF_MONTH); |
296 |
} else if (dateTimeFieldTypes[i].equals(org.joda.time.DateTimeFieldType.hourOfDay())){ |
297 |
initializePartialsIteration(types, values, jodaValues[i], AbsoluteInstantType.HOUR_OF_DAY); |
298 |
} else if (dateTimeFieldTypes[i].equals(org.joda.time.DateTimeFieldType.minuteOfHour())){ |
299 |
initializePartialsIteration(types, values, jodaValues[i], AbsoluteInstantType.MINUTE_OF_HOUR); |
300 |
} else if (dateTimeFieldTypes[i].equals(org.joda.time.DateTimeFieldType.secondOfMinute())){ |
301 |
initializePartialsIteration(types, values, jodaValues[i], AbsoluteInstantType.SECOND_OF_MINUTE); |
302 |
} else if (dateTimeFieldTypes[i].equals(org.joda.time.DateTimeFieldType.millisOfSecond())){ |
303 |
initializePartialsIteration(types, values, jodaValues[i], AbsoluteInstantType.MILLIS_OF_SECOND); |
304 |
} |
305 |
} |
306 |
int[] nativeTypes = new int[types.size()]; |
307 |
int[] nativeValues = new int[values.size()]; |
308 |
for (int i=0 ; i<types.size() ; i++){ |
309 |
nativeTypes[i] = (Integer)types.get(i);
|
310 |
nativeValues[i] = (Integer)values.get(i);
|
311 |
} |
312 |
try {
|
313 |
this.endAbsoluteInstant = timeSupportManager.createAbsoluteInstant(nativeTypes, nativeValues, chronology);
|
314 |
} catch (AbsoluteInstantTypeNotRegisteredException e) {
|
315 |
LOG.error("Impossible to create the endPartial for a period", e);
|
316 |
} |
317 |
} |
318 |
|
319 |
@SuppressWarnings({ "unchecked" }) |
320 |
private void initializePartialsIteration(List types, List values, int jodaValue, int dateTimefieldtype){ |
321 |
boolean found = false; |
322 |
for (int j=0 ; j<types.size() ; j++){ |
323 |
if (types.get(j).equals(dateTimefieldtype)){
|
324 |
int value = (Integer)values.get(j); |
325 |
values.remove(j); |
326 |
values.add(j, value + jodaValue); |
327 |
found = true;
|
328 |
break;
|
329 |
} |
330 |
} |
331 |
if (!found){
|
332 |
types.add(dateTimefieldtype); |
333 |
values.add(jodaValue); |
334 |
} |
335 |
} |
336 |
|
337 |
public int size() { |
338 |
return jodaPeriod.size();
|
339 |
} |
340 |
|
341 |
public AbsoluteIntervalType getFieldType(int index) { |
342 |
return absoluteIntervalTypes[index];
|
343 |
} |
344 |
|
345 |
public int getValue(int index) { |
346 |
return jodaPeriod.getValue(index);
|
347 |
} |
348 |
|
349 |
public String toString() { |
350 |
return jodaPeriod.toString();
|
351 |
} |
352 |
|
353 |
public boolean equals(Object obj) { |
354 |
if (!(obj instanceof DefaultAbsoluteInterval)){ |
355 |
return false; |
356 |
} |
357 |
return ((DefaultAbsoluteInterval)obj).getJodaType().equals(jodaPeriod);
|
358 |
} |
359 |
|
360 |
org.joda.time.Period getJodaType() { |
361 |
return jodaPeriod;
|
362 |
} |
363 |
|
364 |
public Chronology getChronology() {
|
365 |
return chronology;
|
366 |
} |
367 |
|
368 |
public int getYears() { |
369 |
return jodaPeriod.getYears();
|
370 |
} |
371 |
|
372 |
public int getMonths() { |
373 |
return jodaPeriod.getMonths();
|
374 |
} |
375 |
|
376 |
public int getWeeks() { |
377 |
return jodaPeriod.getWeeks();
|
378 |
} |
379 |
|
380 |
public int getDays() { |
381 |
return jodaPeriod.getDays();
|
382 |
} |
383 |
|
384 |
public int getHours() { |
385 |
return jodaPeriod.getHours();
|
386 |
} |
387 |
|
388 |
public int getMinutes() { |
389 |
return jodaPeriod.getMinutes();
|
390 |
} |
391 |
|
392 |
public int getSeconds() { |
393 |
return jodaPeriod.getSeconds();
|
394 |
} |
395 |
|
396 |
public int getMillis() { |
397 |
return jodaPeriod.getMillis();
|
398 |
} |
399 |
|
400 |
public boolean isAfter(AbsoluteInterval period) { |
401 |
return jodaPeriod.getMillis() > period.getMillis();
|
402 |
} |
403 |
|
404 |
public boolean isBefore(AbsoluteInterval period) { |
405 |
return jodaPeriod.getMillis() < period.getMillis();
|
406 |
} |
407 |
|
408 |
public Object clone() throws CloneNotSupportedException { |
409 |
return new DefaultAbsoluteInterval(chronology, new org.joda.time.Period(jodaPeriod)); |
410 |
} |
411 |
|
412 |
public AbsoluteInstant getStart(){
|
413 |
return startAbsoluteInstant;
|
414 |
} |
415 |
|
416 |
public AbsoluteInstant getEnd(){
|
417 |
return endAbsoluteInstant;
|
418 |
} |
419 |
|
420 |
public final boolean isRelative() { |
421 |
return false; |
422 |
} |
423 |
|
424 |
public boolean isAbsolute() { |
425 |
return true; |
426 |
} |
427 |
|
428 |
public boolean isInterval() { |
429 |
return true; |
430 |
} |
431 |
|
432 |
public final boolean isInstant() { |
433 |
return false; |
434 |
} |
435 |
|
436 |
public boolean intersects(Time time) { |
437 |
if (time.isAbsolute()){
|
438 |
if (time.isInterval()){
|
439 |
return intersects((AbsoluteInterval)time);
|
440 |
}else{
|
441 |
return contains((AbsoluteInstant)time);
|
442 |
} |
443 |
} |
444 |
return true; |
445 |
} |
446 |
|
447 |
public boolean intersects(AbsoluteInterval absoluteInsterInterval){ |
448 |
return (this.getStart().isAfter(absoluteInsterInterval.getStart()) && this.getEnd().isBefore(absoluteInsterInterval.getStart())) || |
449 |
(this.getEnd().isBefore(absoluteInsterInterval.getEnd()) && this.getEnd().isAfter(absoluteInsterInterval.getEnd())); |
450 |
} |
451 |
|
452 |
public boolean contains(Instant instant) { |
453 |
if (instant.isAbsolute()){
|
454 |
return this.getMillis() >= ((AbsoluteInstant)instant).getMillis(); |
455 |
} |
456 |
return false; |
457 |
} |
458 |
|
459 |
public Duration toStandardDuration() { |
460 |
long millis = 0; |
461 |
millis += getYears() * MILLIS_BY_YEAR; |
462 |
millis += getMonths() * MILLIS_BY_MONTH; |
463 |
millis += getDays() * MILLIS_BY_YEAR; |
464 |
millis += getHours() * MILLIS_BY_HOUR; |
465 |
millis += getMinutes() * MILLIS_BY_MINUTE; |
466 |
millis += getSeconds() * MILLIS_BY_SECOND; |
467 |
millis += getMillis(); |
468 |
return new DefaultDuration(millis); |
469 |
} |
470 |
|
471 |
} |
472 |
|