将字符串转换为GWT上的日期 [英] convert String to Date on GWT

查看:84
本文介绍了将字符串转换为GWT上的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用GWT 2.0.3将字符串转换为日期或日期为字符串?

How do I convert String to Date or Date to String using GWT 2.0.3?

推荐答案

java.util.Date 类本身: parse(String s) toString()。虽然第一个已被弃用,但它是与GWT一起使用的方法。如果您想更好地控制Date的格式,转换为String时使用GWT特定的类: com.google.gwt.i18n.client.DateTimeFormat 。它会根据模式格式化日期,类似于Java自己的 SimpleDateFormat

With the methods on the java.util.Date class itself: parse(String s) and toString(). Although the first is deprecated it is the method to use with GWT. If you want more control over how the Date is formatted, when converting to String use the GWT specific class: com.google.gwt.i18n.client.DateTimeFormat. It will format the date given a pattern, similar to Java's own SimpleDateFormat.

这篇关于将字符串转换为GWT上的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆