-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate timestamp parameters in sample xapi-server (#191)
- Loading branch information
Showing
3 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
samples/xapi-server/src/main/java/dev/learning/xapi/samples/xapiserver/InstantConverter.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 2016-2023 Berry Cloud Ltd. All rights reserved. | ||
*/ | ||
|
||
package dev.learning.xapi.samples.xapiserver; | ||
|
||
import dev.learning.xapi.jackson.model.strict.XapiTimestamp; | ||
import java.time.Instant; | ||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* <p> | ||
* InstantConverter class. | ||
* </p> | ||
* | ||
* @author István Rátkai (Selindek) | ||
* @author Thomas Turrell-Croft | ||
*/ | ||
@Component | ||
public class InstantConverter implements Converter<String, Instant> { | ||
|
||
/** | ||
* Converts string to {@link java.time.Instant}. If the timezone is not specified in string, UTC | ||
* will be used. | ||
* | ||
* @param source the String representation of the datetime in ISO 8601 format (e.q. | ||
* '2011-12-03T10:15:30+01:00') | ||
* | ||
* @return {@link java.time.Instant} of source input | ||
*/ | ||
@Override | ||
public Instant convert(String source) { | ||
|
||
return XapiTimestamp.parse(source); | ||
} | ||
|
||
} |
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
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