当前位置:网站首页>The database records are read through the system time under the Android system, causing the problem of incomplete Reading Records!
The database records are read through the system time under the Android system, causing the problem of incomplete Reading Records!
2022-06-25 15:59:00 【Favorite grapes】
Android Under the system, read the database records through the system time , The reading record is incomplete !
demand
There are some records stored in the database , Time stamped . I need to read the data of the day ( according to Android Read the time of the plate )
So we have the following code :
Calendar instance = Calendar.getInstance();
instance.set(Calendar.SECOND, 0);
instance.set(Calendar.HOUR, 0);
instance.set(Calendar.MINUTE, 0);
instance.set(Calendar.MILLISECOND, 0);
long startTime = instance.getTimeInMillis();
instance.set(Calendar.SECOND, 59);
instance.set(Calendar.HOUR, 23);
instance.set(Calendar.MINUTE, 59);
long endTime = instance.getTimeInMillis();
session.queryBuilder(XXX.class)
.// Here are N Many other conditions
.where(XXXDao.Properties.Time.between(startTime, endTime))
.list();
result :
No problem running on my tablet , Running on most tablets is no problem .
Problem finding
There is a tablet in the test hand , One problem I found was , The record clearly shows the data of the day , But I just can't find it .
Problem solving process
First of all, I suspect that the database did not retrieve the data , So get rid of the other conditions , Start checking the database , It turns out that the data .
So the start judgment is that there is a problem with my start time and end time .
So the breakpoint is , Look at the data in the database , What is the difference between my start time and my end time .
Results found , The start time is greater than the timestamp of all data .
therefore , I guess there is a mistake in the above time calculation , Check the time setting code , Found out
instance.set(Calendar.HOUR, 0);
It's used here Calendar.HOUR
, Suddenly think of , There seems to be another one Calendar.HOUR_OF_DAY
.
So it was changed to Calendar.HOUR_OF_DAY
.
The test again , And calculate the timestamp , Found it right , The records are also read out ~~
边栏推荐
- NFT元宇宙发展能做什么?
- Resolve Visio and office365 installation compatibility issues
- What is the NFT digital collection?
- 原生js动态添加元素
- Sword finger offer II 091 Paint the house
- Educational administration system development (php+mysql)
- Optimization of lazyagg query rewriting in parsing data warehouse
- TFIDF与BM25
- Power representation in go language
- Lifeifei's team applied vit to the robot, increased the maximum speed of planning reasoning by 512 times, and also cued hekaiming's MAE
猜你喜欢
Binocular 3D perception (I): preliminary understanding of binocular
The paid video at station B caused the up master to lose more than ten thousand fans
Don't underestimate the integral mall, its role can be great!
AutoK3s v0.5.0 发布 延续简约和友好
The release of autok3s v0.5.0 continues to be simple and friendly
golang使用mongo-driver操作——增(进阶)
Prototype mode
Classic deadlock scenario of multithreading and its solution (philosopher dining problem)
Inter thread synchronization semaphore control
说下你对方法区演变过程和内部结构的理解
随机推荐
深度学习 pytorch cifar10数据集训练「建议收藏」
Mt60b1g16hc-48b:a micron memory particles FBGA code d8bnk[easy to understand]
说下你对方法区演变过程和内部结构的理解
有哪些新手程序员不知道的小技巧?
MySQL modify field statement
Report on Hezhou air32f103cbt6 development board
Lifeifei's team applied vit to the robot, increased the maximum speed of planning reasoning by 512 times, and also cued hekaiming's MAE
f_ Read function [easy to understand]
VectorDraw Developer Framework 10.1001 Crack
Jz-065 path in matrix
JS的注释
Pytest测试框架笔记
Differences between = = and = = = in JS (detailed explanation)
Mapbox map - inconsistent coordinate system when docking GIS layers?
MySQL installation tutorial
不要小看了积分商城,它的作用可以很大!
揭秘GaussDB(for Redis):全面对比Codis
What are the reasons why the game industry needs high defense servers?
[problem solving] dialogfragment can not be attached to a container view
Don't underestimate the integral mall, its role can be great!