如何使用play框架和scala获取系统时间?
发布时间:2020-12-16 18:43:49 所属栏目:安全 来源:网络整理
导读:如何使用play框架和 scala获取系统时间? 使用playframework2.0和scala获取系统时间到web程序是有什么不同的方式… 解决方法 如果要将系统时间粘贴到Twirl html模板中,只需在System之前添加@符号即可 @System.currentTimeMillis 要么 @System.nanoTime 更新
如何使用play框架和
scala获取系统时间?
使用playframework2.0和scala获取系统时间到web程序是有什么不同的方式… 解决方法
如果要将系统时间粘贴到Twirl html模板中,只需在System之前添加@符号即可
@System.currentTimeMillis 要么 @System.nanoTime 更新 如果你需要一些当前时间的格式,那么在你的Twirl模板中添加一些帮助方法,如下所示: @currentTime = @{ import java.util.Calendar import java.text.SimpleDateFormat val today = Calendar.getInstance.getTime val curTimeFormat = new SimpleDateFormat("HH:mm") curTimeFormat.format(today) } 然后在模板中简单地调用此方法: <div>@currentTime</div> 你可以在这里阅读Twirld模板引擎:Scala Template (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |