Commit 8f252221 authored by Liang Ding's avatar Liang Ding

🐛 #12435

parent 347b3701
......@@ -65,15 +65,28 @@ public class ArchiveDateRepositoryImpl extends AbstractRepository implements Arc
LOGGER.log(Level.TRACE, "Archive date [{0}] parsed to time [{1}]", archiveDate, time);
final Query query = new Query();
query.setFilter(new PropertyFilter(ArchiveDate.ARCHIVE_TIME, FilterOperator.EQUAL, time)).setPageCount(1);
Query query = new Query().setFilter(new PropertyFilter(ArchiveDate.ARCHIVE_TIME, FilterOperator.EQUAL, time)).
setPageCount(1);
JSONObject result = get(query);
JSONArray array = result.optJSONArray(Keys.RESULTS);
if (0 == array.length()) {
// Try to fix wired timezone issue: https://github.com/b3log/solo/issues/12435
try {
time = DateUtils.parseDate(archiveDate, new String[]{"yyyy/MM"}).getTime();
time += 60 * 1000 * 60 * 8;
} catch (final ParseException e) {
return null;
}
final JSONObject result = get(query);
final JSONArray array = result.optJSONArray(Keys.RESULTS);
LOGGER.log(Level.TRACE, "Fix archive date [{0}] parsed to time [{1}]", archiveDate, time);
if (0 == array.length()) {
return null;
query = new Query().setFilter(new PropertyFilter(ArchiveDate.ARCHIVE_TIME, FilterOperator.EQUAL, time)).
setPageCount(1);
result = get(query);
array = result.optJSONArray(Keys.RESULTS);
if (0 == array.length()) {
return null;
}
}
return array.optJSONObject(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment