当前位置:网站首页>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 ~~
边栏推荐
- Time wheel and implementation analysis of time wheel in go zero
- 免费送书啦!火遍全网的AI给老照片上色,这里有一份详细教程!
- 《睡眠公式》:怎么治睡不好?
- Converting cifar10 datasets
- Do you want to go to an outsourcing company? This article will give you a comprehensive understanding of outsourcing pits!
- Leetcode topic [array]-34- find the first and last positions of elements in a sorted array
- Ten routing strategies for distributed task scheduling platform XXL job
- 说下你对方法区演变过程和内部结构的理解
- 读配置、讲原理、看面试真题,我只能帮你到这了。。。
- Educational administration system development (php+mysql)
猜你喜欢

Resolve Visio and office365 installation compatibility issues

Educational administration system development (php+mysql)

Binocular 3D perception (I): preliminary understanding of binocular

《睡眠公式》:怎么治睡不好?

Sword finger offer II 091 Paint the house

不要小看了积分商城,它的作用可以很大!
[golang] leetcode intermediate - find the first and last position of an element in a sorted array & Merge interval

Do you want to go to an outsourcing company? This article will give you a comprehensive understanding of outsourcing pits!

Stop "outsourcing" Ai models! The latest research finds that some "back doors" that undermine the security of machine learning models cannot be detected
Create raspberry PI image file of raspberry pie
随机推荐
Programmer vs hacker thinking | daily anecdotes
Why is it said that restarting can solve 90% of the problems
golang reverse a slice
合宙Air32F103CBT6開發板上手報告
js 给元素添加自定义属性
镁光256Gb NAND Flash芯片介绍
Built in methods for data types
Prototype mode
Mark the same items in the Li list in red
Understand the execution sequence of try catch finally in one diagram
Continuous integration of aspnetcore & cloud flow
Sleep formula: how to cure bad sleep?
Practice of geospatial data in Nepal graph
Leetcode topic [array]-34- find the first and last positions of elements in a sorted array
MySQL modify field statement
原生js动态添加元素
元宇宙系统的概念解析
Binocular 3D perception (I): preliminary understanding of binocular
Native JS dynamically add elements
Client development (electron) system level API usage