[英]how to replace the deprecated constructor Date(int, int, int) in JAVA GWT?
I'm working on an existing GWT app . 我正在开发一个现有的GWT应用程序。 I'm seeing this warning 我看到了这个警告
the constructor Date(int, int, int) is deprecated 不推荐使用构造函数Date(int,int,int)
Since java.util.Calendar is not supported in GWT client side , I'm looking for how to replace this methode . 由于GWT客户端不支持java.util.Calendar,我正在寻找如何替换这种方法。
There's no replacement for GWT (for now at least, java.time
support/emulation should come some time in the future). GWT没有替代品(至少现在, java.time
支持/仿真将来会有一段时间)。 Just put @SuppressWarnings("deprecation")
if you want to get rid of the warning. 如果你想摆脱警告,只需加上@SuppressWarnings("deprecation")
。
Use always Calendar (GregorianCalendar would suit what you need). 始终使用日历(GregorianCalendar适合您的需要)。 And when you need to turn it into a Date object, use Calendar.getTime() 当您需要将其转换为Date对象时,请使用Calendar.getTime()
This page has examples: http://www.mkyong.com/java/java-date-and-calendar-examples/ 此页面包含示例: http : //www.mkyong.com/java/java-date-and-calendar-examples/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.