如何存储下午6:00在Android的SQLite数据库 [英] how to store 6:00pm in sqlite database in android
问题描述
任何人可以帮助我如何保存下午6:00(时间上午或下午)在SQLite数据库中的Android
根据你想要做的人会选择不同的数据格式时是什么。如果只为presentation使用String只是因为它是在源码这就是所谓的文字。如果你需要某种计算,那么我会去java.util.Date和其长期的价值存储为一个整数。
如果你不需要毫秒precision,试试这个
日期D =新的日期();
INT时间戳=(INT)(d.getTime()/ 1000L / 60L);
总之需要做一些解析和格式化。 http://www.sqlite.org/datatype3.html 解释了SQLite的
can anybody help me how to store 6:00pm(time with am or pm) in sqlite database in android
Depending on what you want to do with the time one might chose different data formats. If just for presentation use the String just as it is, in sqlite this is called TEXT. If you need to some kind of calculation, then I would go for java.util.Date and store its long value as an INTEGER.
If you don't need millisecond precision, try this
Date d = new Date();
int timestamp = (int) (d.getTime() / 1000L / 60L);
Anyhow will need to do some parsing and formatting. http://www.sqlite.org/datatype3.html explains data types for SQLite
这篇关于如何存储下午6:00在Android的SQLite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!