简体   繁体   English

如何在JAVA GWT中替换弃用的构造函数Date(int,int,int)?

[英]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")

I believe this will help answer your question. 我相信有助于回答你的问题。

You can use the Calendar.set() and Calendar.get() methods to set/get the date. 您可以使用Calendar.set()Calendar.get()方法来设置/获取日期。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM