This repository has been archived by the owner on Oct 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #15
- Loading branch information
Showing
21 changed files
with
378 additions
and
217 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...waway-prototype/common/src/main/java/com/rometools/rome/common/parser/DateTimeParser.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,32 @@ | ||
package com.rometools.rome.common.parser; | ||
|
||
import com.rometools.rome.common.value.DateTimeValue; | ||
import java.time.ZonedDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
public class DateTimeParser implements Parser<DateTimeValue> { | ||
|
||
public static final DateTimeParser INSTANCE = new DateTimeParser(); | ||
|
||
private static DateTimeFormatter formatter = | ||
DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss z"); | ||
|
||
@Override | ||
public Class<DateTimeValue> getResultClass() { | ||
return DateTimeValue.class; | ||
} | ||
|
||
@Override | ||
public DateTimeValue parse(String input) { | ||
if (input.isEmpty()) { | ||
return DateTimeValue.none(); | ||
} | ||
|
||
return DateTimeValue.of(ZonedDateTime.parse(input, formatter)); | ||
} | ||
|
||
@Override | ||
public DateTimeValue none() { | ||
return DateTimeValue.none(); | ||
} | ||
} |
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
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
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
Oops, something went wrong.