-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from cibotech/LocalDateAndInstantParsers
Implement Instant.parse and LocalDate.parse.
- Loading branch information
Showing
7 changed files
with
226 additions
and
21 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
package java.time | ||
|
||
import java.time.format.DateTimeParseException | ||
|
||
private[time] object Preconditions { | ||
// Like scala.Predef.require, but throws a DateTimeException. | ||
def requireDateTime(requirement: Boolean, message: => Any): Unit = { | ||
if (!requirement) | ||
throw new DateTimeException(message.toString) | ||
} | ||
|
||
def requireDateTimeParse(requirement: Boolean, message: => Any, | ||
charSequence: CharSequence, index: Int): Unit = { | ||
if (!requirement) | ||
throw new DateTimeParseException(message.toString, charSequence, index) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/scala/java/time/format/DateTimeParseException.scala
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,14 @@ | ||
package java.time.format | ||
|
||
import java.time.DateTimeException | ||
|
||
class DateTimeParseException(message: String, parsedData: CharSequence, | ||
errorIndex: Int, cause: Throwable) | ||
extends DateTimeException(message, cause) { | ||
|
||
def this(message: String, parsedData: CharSequence, errorIndex: Int) = | ||
this(message, parsedData, errorIndex, null) | ||
|
||
def getErrorIndex(): Int = errorIndex | ||
def getParsedString(): String = parsedData.toString | ||
} |
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