问题标签 [android-date]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
23 回答
570053 浏览

android - 在 Android 应用程序中显示当前时间和日期

如何在 Android 应用程序中显示当前日期和时间?

0 投票
4 回答
8426 浏览

android - Android DatePicker 日期限制

我在我的活动中使用 DatePicket ,

我想将用户选择的日期限制为今天的日期。

他们不应该选择大于今天日期的日期。

谢谢你。

0 投票
5 回答
29037 浏览

java - 将日期字符串转换为不同的格式

我有一个包含日期格式的字符串YYYY-MM-DD

您如何建议我以DD-MM-YYYY最好的方式将其转换为格式?

这就是我天真地做的方式:

但是还有其他更优雅、更有效的方法吗?IE。使用一些内置功能?我一直无法找到一个,同时快速搜索 API。

这里有人知道另一种方法吗?

0 投票
2 回答
7674 浏览

android - 如何确定设备使用的是 12 小时还是 24 小时时间格式?

我想知道当前的设备时间格式。

表示 24 小时/12 小时格式。

请让我知道我该如何确定。

是否有任何 API 可以确定这一点。

谢谢。

0 投票
1 回答
492 浏览

android - 在 Android 中创建日期选择器时出错?

在 android 中创建日期选择器时出现此错误 "Syntax error on tokens, AnnotationName expected instead"

这是发生错误的代码。有人可以建议我如何消除此错误吗?

0 投票
2 回答
530 浏览

android - SQL 语句在两个日期之间不返回值

我正在尝试在两个日期之间选择一个特定日期。它存储在数据库中的格式是M/d/yyyy. 我想要做的是传递两个日期,我想选择这两个日期之间的列的所有数据。我知道数据库中有数据,但它不会在某些日期带来任何东西。对于某些日期,它会带来数据,但对于某些日期,它会带来数据。

例子:

当我选择 2011 年 7 月 10 日作为第一个日期,并选择 2011 年 7 月 16 日作为第二个日期时,它会带来数据。但是当我选择 2011 年 7 月 9 日作为第一次约会和 2011 年 7 月 16 日作为第二次约会时,它不会带来任何东西。

这是我的查询:

如果有人可以帮助解决这个问题。谢谢!

0 投票
1 回答
920 浏览

android - Date getMonth() in java from 0-11 messes up searches in database?

Second EDIT:

Looks like my issue might be where the date is set from the date picker dialog:

I am +1 to the month, but never taking that off again when i compare for the database...

EDIT: Okay I did double checked this (finally got to it). Sure enough the

So the date retrieved from the database is the right date. The one that comes back from my dialog even though it displays correctly using:

...is actually a month ahead when I look at the object as cobj.getTime().getTime(); (a long for the dates I use). Is there some other method or conversion I am missing?

Should I not be using the .getTime on the Calendar Object just to get a long from that (with a call to getTime again on the Date object?). Sometimes it seems to me that my best bet is to store longs in milliseconds to the database and then just retrieve them and do the Date conversions there?

PRE-EDIT question:

SO I have this Date field in a database, that I can store a date to and read a date from, when I read em... I have to add a +1 to the .getMonth() because date returns that as a number 0-11, instead of 1-12. After dealing with this issue and a few others (like .getMinutes returning an int, so if the time is 5:00 only 5:0 is displayed?)but I finally got the date displaying just great, but I found out when I try to query the database on a date things are off I am guessing by one month. So that means a month of

9/8/2011

(dd/mm/YYYY) format, will not query right when using the following ORMLite query:(Notice the .qe, GreaterThanEqual in ormlite).

So I must be handling dates wrong, maybe adding to the month for display purposes is not right? or something... maybe in my query with the Calendar object, I can make that month part 0-11 or something...not sure what avenue to take here.

0 投票
2 回答
1058 浏览

android - 日历显示错误的日期和时间

此代码显示 05-02-01 作为日期,而不是今天的日期 (25-08-2011) 谁能告诉我发生了什么?

关于桑迪普

0 投票
1 回答
136 浏览

android - 在android中以繁体中文获取日期

我使用下面的代码从时间戳获取日期:

java.util.Date d = new java.util.Date(Long.parseLong(created_at) * 1000);

我目前正在获取英文日期,但我想要繁体中文。有可能这样做吗?

0 投票
17 回答
197374 浏览

java - 如何在android中将毫秒转换为日期格式?

我有毫秒。我需要将其转换为日期格式

例子:

23/10/2011

如何实现?