Android DatePreference 默认值未设置?

发布于 2024-11-10 14:24:10 字数 71 浏览 5 评论 0原文

如何从 Java 端设置 DatePreference 默认值。

我想“现在”设定日期,

谢谢。

How To Set DatePreference Default Value From Java Side.

I Want Set to Date "Now"

thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谷夏 2024-11-17 14:24:10

我不太确定你在问什么,因为我不知道什么是“DatePreference”,谷歌也不知道。

使用 Java 和 Android,您可以使用多种选项来表示和处理日期/时间数据。要表示“现在”:

我还建议在使用时查看 android.os.SystemClock 文档Android 中的日期/时间事件。

I'm not exactly sure what you're asking about, as I don't know what a "DatePreference" is, and neither does Google.

With Java and Android, you have a few options for representing and working with date/time data. To represent "Now":

  • You could use java.util.Date. The no argument constructor creates a Date object that "represents the time at which it was allocated".

  • You could use java.util.Calendar. Calendar.getInstance() returns "a Calendar subclass instance set to the current date and time in the default Timezone".

  • You could use a primitive long value. System.currentTimeMillis() returns "the current time in milliseconds".

  • You could use android.text.format.Time, which is "a faster replacement for" Calendar. After constructing or otherwise obtaining a Time object, call setToNow() to set the time "to the current time".

  • Before Android, I know a lot of folks preferred to use Joda-Time when working with date/time data in Java. With Joda-Time, you could create a new joda.time.DateTime instance with the no argument constructor, which would then represent "the current system millisecond time using ISOChronology in the default time zone".

I also recommend reviewing the android.os.SystemClock documentation, when working with date/time events in Android.

迟月 2024-11-17 14:24:10

我找到了解决方案

dpDate.setDate(tools.NowDate());

I Found Solution This

dpDate.setDate(tools.NowDate());

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文