开发者

Bind a Date in milliseconds representation

I need to bind a Date using the milliseconds representation in a controller (i.e. milliseconds from 01.01.1970). I tried using @As("S") but had no success, it fails as soon the value is at least 1000. Is there really no way to do this without writing a custom binder?

Edit: Seems li开发者_运维知识库ke writing a custom binder is the way to go because Play's DateBinder uses SimpleDateFormat and because of this bug. SimpleDateFormat doesn't accept these kinds of formats.


AFAIK there's no way, because the binder is just trying to parse expecting the date fields (and the Date millisec field are just 3 digit), and it will not calculate anything.

It's better to bind millisecs to Long and then create Date with it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜