Create java.util.Date TypeMapper. And add the currentDate method.

This commit is contained in:
shimamoto
2013-06-23 20:46:08 +09:00
parent 83ff171782
commit 4326f34ef5
12 changed files with 68 additions and 74 deletions

View File

@@ -50,11 +50,11 @@ abstract class ControllerBase extends ScalatraFilter with ClientSideValidationFo
/**
* ValueType for the Date property.
*/
def date(constraints: Constraint*): SingleValueType[java.sql.Date] =
new SingleValueType[java.sql.Date]((pattern("\\d{4}-\\d{2}-\\d{2}") +: constraints): _*){
def convert(value: String): java.sql.Date = {
def date(constraints: Constraint*): SingleValueType[java.util.Date] =
new SingleValueType[java.util.Date]((pattern("\\d{4}-\\d{2}-\\d{2}") +: constraints): _*){
def convert(value: String): java.util.Date = {
val formatter = new java.text.SimpleDateFormat("yyyy-MM-dd")
new java.sql.Date(formatter.parse(value).getTime)
formatter.parse(value)
}
}