当前位置:网站首页>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 ~~
边栏推荐
- [issue 24] one year experience of golang to develop futu
- 基于神经标签搜索,中科院&微软亚研零样本多语言抽取式摘要入选ACL 2022
- Free books! AI across the Internet paints old photos. Here is a detailed tutorial!
- Source code analysis of nine routing strategies for distributed task scheduling platform XXL job
- [golang] leetcode intermediate - find the first and last position of an element in a sorted array & Merge interval
- Take you to the open source project of smart home: the preliminary configuration of zhiting home cloud and home assistant+ homebridge
- TensorFlow加载cifar10数据集
- 合宙Air32F103CBT6開發板上手報告
- Programmer vs hacker thinking | daily anecdotes
- QC, QA, IPQC, JQE, DQA, SQE, DQC, MQC, IQC, FQC, OQC
猜你喜欢
Time wheel and implementation analysis of time wheel in go zero

Advanced SQL statement 1 of Linux MySQL database

Golang uses Mongo driver operation - increase (Advanced)

Don't underestimate the integral mall, its role can be great!

Sword finger offer 04 Find in 2D array

基于深度Q学习的雅达利打砖块游戏博弈
Take you to the open source project of smart home: the preliminary configuration of zhiting home cloud and home assistant+ homebridge

Optimization of lazyagg query rewriting in parsing data warehouse
How to debug grpc by postman

Do you want to go to an outsourcing company? This article will give you a comprehensive understanding of outsourcing pits!
随机推荐
Message format of Modbus (PLC)
Do you want to go to an outsourcing company? This article will give you a comprehensive understanding of outsourcing pits!
Continuous integration of aspnetcore & cloud flow
TFIDF and BM25
Rxjs TakeUntil 操作符的学习笔记
加载本地cifar10 数据集
不要再「外包」AI 模型了!最新研究发现:有些破坏机器学习模型安全的「后门」无法被检测到
面试官:你简历上说精通mysql,那你说下聚簇/联合/覆盖索引、回表、索引下推
Cloning and importing DOM nodes
Write one file to the marked location of another file
Linux-MySQL数据库之高级SQL 语句一
Understand the execution sequence of try catch finally in one diagram
f_ Read function [easy to understand]
What are the reasons why the game industry needs high defense servers?
Lecun predicts AgI: big model and reinforcement learning are both ramps! My "world model" is the new way
LeCun预言AGI:大模型和强化学习都是斜道!我的「世界模型」才是新路
Ten routing strategies for distributed task scheduling platform XXL job
How to convert a recorded DOM to a video file
GridLayout evenly allocate space
什么是oa