-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,351 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...integrity/parameter/conversion/conversions/integrity/dates/DateAndTimeValueToInstant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*******************************************************************************/ | ||
package de.gebit.integrity.parameter.conversion.conversions.integrity.dates; | ||
|
||
import java.text.ParseException; | ||
import java.time.Instant; | ||
import java.util.Date; | ||
|
||
import de.gebit.integrity.dsl.DateAndTimeValue; | ||
import de.gebit.integrity.parameter.conversion.Conversion; | ||
import de.gebit.integrity.parameter.conversion.ConversionContext; | ||
import de.gebit.integrity.parameter.conversion.ConversionFailedException; | ||
import de.gebit.integrity.utils.DateUtil; | ||
|
||
/** | ||
* A default Integrity conversion. | ||
* | ||
* @author Rene Schneider - initial API and implementation | ||
* | ||
*/ | ||
public class DateAndTimeValueToInstant extends Conversion<DateAndTimeValue, Instant> { | ||
|
||
@Override | ||
public Instant convert(DateAndTimeValue aSource, Class<? extends Instant> aTargetType, | ||
ConversionContext aConversionContext) throws ConversionFailedException { | ||
try { | ||
return DateUtil.convertDateAndTimeValue(aSource).toInstant(); | ||
} catch (ParseException exc) { | ||
throw new ConversionFailedException(DateAndTimeValue.class, Date.class, null, exc); | ||
} | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
...tegrity/parameter/conversion/conversions/integrity/dates/DateAndTimeValueToLocalDate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*******************************************************************************/ | ||
package de.gebit.integrity.parameter.conversion.conversions.integrity.dates; | ||
|
||
import java.text.ParseException; | ||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.ZoneId; | ||
import java.util.Date; | ||
|
||
import de.gebit.integrity.dsl.DateAndTimeValue; | ||
import de.gebit.integrity.parameter.conversion.Conversion; | ||
import de.gebit.integrity.parameter.conversion.ConversionContext; | ||
import de.gebit.integrity.parameter.conversion.ConversionFailedException; | ||
import de.gebit.integrity.utils.DateUtil; | ||
|
||
/** | ||
* A default Integrity conversion. | ||
* | ||
* @author Rene Schneider - initial API and implementation | ||
* | ||
*/ | ||
public class DateAndTimeValueToLocalDate extends Conversion<DateAndTimeValue, LocalDate> { | ||
|
||
@Override | ||
public LocalDate convert(DateAndTimeValue aSource, Class<? extends LocalDate> aTargetType, | ||
ConversionContext aConversionContext) throws ConversionFailedException { | ||
try { | ||
return LocalDateTime | ||
.from(DateUtil.convertDateAndTimeValue(aSource).toInstant().atZone(ZoneId.systemDefault())) | ||
.toLocalDate(); | ||
} catch (ParseException exc) { | ||
throw new ConversionFailedException(DateAndTimeValue.class, Date.class, null, exc); | ||
} | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...ity/parameter/conversion/conversions/integrity/dates/DateAndTimeValueToLocalDateTime.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*******************************************************************************/ | ||
package de.gebit.integrity.parameter.conversion.conversions.integrity.dates; | ||
|
||
import java.text.ParseException; | ||
import java.time.LocalDateTime; | ||
import java.time.ZoneId; | ||
import java.util.Date; | ||
|
||
import de.gebit.integrity.dsl.DateAndTimeValue; | ||
import de.gebit.integrity.parameter.conversion.Conversion; | ||
import de.gebit.integrity.parameter.conversion.ConversionContext; | ||
import de.gebit.integrity.parameter.conversion.ConversionFailedException; | ||
import de.gebit.integrity.utils.DateUtil; | ||
|
||
/** | ||
* A default Integrity conversion. | ||
* | ||
* @author Rene Schneider - initial API and implementation | ||
* | ||
*/ | ||
public class DateAndTimeValueToLocalDateTime extends Conversion<DateAndTimeValue, LocalDateTime> { | ||
|
||
@Override | ||
public LocalDateTime convert(DateAndTimeValue aSource, Class<? extends LocalDateTime> aTargetType, | ||
ConversionContext aConversionContext) throws ConversionFailedException { | ||
try { | ||
return LocalDateTime | ||
.from(DateUtil.convertDateAndTimeValue(aSource).toInstant().atZone(ZoneId.systemDefault())); | ||
} catch (ParseException exc) { | ||
throw new ConversionFailedException(DateAndTimeValue.class, Date.class, null, exc); | ||
} | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
...tegrity/parameter/conversion/conversions/integrity/dates/DateAndTimeValueToLocalTime.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*******************************************************************************/ | ||
package de.gebit.integrity.parameter.conversion.conversions.integrity.dates; | ||
|
||
import java.text.ParseException; | ||
import java.time.LocalDateTime; | ||
import java.time.LocalTime; | ||
import java.time.ZoneId; | ||
import java.util.Date; | ||
|
||
import de.gebit.integrity.dsl.DateAndTimeValue; | ||
import de.gebit.integrity.parameter.conversion.Conversion; | ||
import de.gebit.integrity.parameter.conversion.ConversionContext; | ||
import de.gebit.integrity.parameter.conversion.ConversionFailedException; | ||
import de.gebit.integrity.utils.DateUtil; | ||
|
||
/** | ||
* A default Integrity conversion. | ||
* | ||
* @author Rene Schneider - initial API and implementation | ||
* | ||
*/ | ||
public class DateAndTimeValueToLocalTime extends Conversion<DateAndTimeValue, LocalTime> { | ||
|
||
@Override | ||
public LocalTime convert(DateAndTimeValue aSource, Class<? extends LocalTime> aTargetType, | ||
ConversionContext aConversionContext) throws ConversionFailedException { | ||
try { | ||
return LocalDateTime | ||
.from(DateUtil.convertDateAndTimeValue(aSource).toInstant().atZone(ZoneId.systemDefault())) | ||
.toLocalTime(); | ||
} catch (ParseException exc) { | ||
throw new ConversionFailedException(DateAndTimeValue.class, Date.class, null, exc); | ||
} | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
...ity/parameter/conversion/conversions/integrity/dates/DateAndTimeValueToZonedDateTime.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*******************************************************************************/ | ||
package de.gebit.integrity.parameter.conversion.conversions.integrity.dates; | ||
|
||
import java.text.ParseException; | ||
import java.time.ZonedDateTime; | ||
import java.util.Date; | ||
import java.util.GregorianCalendar; | ||
|
||
import de.gebit.integrity.dsl.DateAndTimeValue; | ||
import de.gebit.integrity.parameter.conversion.Conversion; | ||
import de.gebit.integrity.parameter.conversion.ConversionContext; | ||
import de.gebit.integrity.parameter.conversion.ConversionFailedException; | ||
import de.gebit.integrity.utils.DateUtil; | ||
|
||
/** | ||
* A default Integrity conversion. | ||
* | ||
* @author Rene Schneider - initial API and implementation | ||
* | ||
*/ | ||
public class DateAndTimeValueToZonedDateTime extends Conversion<DateAndTimeValue, ZonedDateTime> { | ||
|
||
@Override | ||
public ZonedDateTime convert(DateAndTimeValue aSource, Class<? extends ZonedDateTime> aTargetType, | ||
ConversionContext aConversionContext) throws ConversionFailedException { | ||
try { | ||
return ((GregorianCalendar) DateUtil.convertDateAndTimeValue(aSource)).toZonedDateTime(); | ||
} catch (ParseException exc) { | ||
throw new ConversionFailedException(DateAndTimeValue.class, Date.class, null, exc); | ||
} | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
.../gebit/integrity/parameter/conversion/conversions/integrity/dates/DateValueToInstant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*******************************************************************************/ | ||
package de.gebit.integrity.parameter.conversion.conversions.integrity.dates; | ||
|
||
import java.text.ParseException; | ||
import java.time.Instant; | ||
import java.util.Date; | ||
|
||
import de.gebit.integrity.dsl.DateValue; | ||
import de.gebit.integrity.parameter.conversion.Conversion; | ||
import de.gebit.integrity.parameter.conversion.ConversionContext; | ||
import de.gebit.integrity.parameter.conversion.ConversionFailedException; | ||
import de.gebit.integrity.utils.DateUtil; | ||
|
||
/** | ||
* A default Integrity conversion. | ||
* | ||
* @author Rene Schneider - initial API and implementation | ||
* | ||
*/ | ||
public class DateValueToInstant extends Conversion<DateValue, Instant> { | ||
|
||
@Override | ||
public Instant convert(DateValue aSource, Class<? extends Instant> aTargetType, | ||
ConversionContext aConversionContext) throws ConversionFailedException { | ||
try { | ||
return DateUtil.convertDateValue(aSource).getTime().toInstant(); | ||
} catch (ParseException exc) { | ||
throw new ConversionFailedException(DateValue.class, Date.class, null, exc); | ||
} | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...ebit/integrity/parameter/conversion/conversions/integrity/dates/DateValueToLocalDate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*******************************************************************************/ | ||
package de.gebit.integrity.parameter.conversion.conversions.integrity.dates; | ||
|
||
import java.text.ParseException; | ||
import java.time.LocalDate; | ||
import java.time.ZoneId; | ||
import java.util.Date; | ||
|
||
import de.gebit.integrity.dsl.DateValue; | ||
import de.gebit.integrity.parameter.conversion.Conversion; | ||
import de.gebit.integrity.parameter.conversion.ConversionContext; | ||
import de.gebit.integrity.parameter.conversion.ConversionFailedException; | ||
import de.gebit.integrity.utils.DateUtil; | ||
|
||
/** | ||
* A default Integrity conversion. | ||
* | ||
* @author Rene Schneider - initial API and implementation | ||
* | ||
*/ | ||
public class DateValueToLocalDate extends Conversion<DateValue, LocalDate> { | ||
|
||
@Override | ||
public LocalDate convert(DateValue aSource, Class<? extends LocalDate> aTargetType, | ||
ConversionContext aConversionContext) throws ConversionFailedException { | ||
try { | ||
return LocalDate | ||
.from(DateUtil.convertDateValue(aSource).getTime().toInstant().atZone(ZoneId.systemDefault())); | ||
} catch (ParseException exc) { | ||
throw new ConversionFailedException(DateValue.class, Date.class, null, exc); | ||
} | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
.../integrity/parameter/conversion/conversions/integrity/dates/DateValueToLocalDateTime.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*******************************************************************************/ | ||
package de.gebit.integrity.parameter.conversion.conversions.integrity.dates; | ||
|
||
import java.text.ParseException; | ||
import java.time.LocalDateTime; | ||
import java.time.ZoneId; | ||
import java.util.Date; | ||
|
||
import de.gebit.integrity.dsl.DateValue; | ||
import de.gebit.integrity.parameter.conversion.Conversion; | ||
import de.gebit.integrity.parameter.conversion.ConversionContext; | ||
import de.gebit.integrity.parameter.conversion.ConversionFailedException; | ||
import de.gebit.integrity.utils.DateUtil; | ||
|
||
/** | ||
* A default Integrity conversion. | ||
* | ||
* @author Rene Schneider - initial API and implementation | ||
* | ||
*/ | ||
public class DateValueToLocalDateTime extends Conversion<DateValue, LocalDateTime> { | ||
|
||
@Override | ||
public LocalDateTime convert(DateValue aSource, Class<? extends LocalDateTime> aTargetType, | ||
ConversionContext aConversionContext) throws ConversionFailedException { | ||
try { | ||
return LocalDateTime | ||
.from(DateUtil.convertDateValue(aSource).getTime().toInstant().atZone(ZoneId.systemDefault())); | ||
} catch (ParseException exc) { | ||
throw new ConversionFailedException(DateValue.class, Date.class, null, exc); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.