【发布时间】:2020-02-10 10:20:27
【问题描述】:
我想计算从数据库中提取日期后的 4 个月。我怎样才能做到这一点。历史输出如下。
2019 年 11 月 27 日星期三 14:42:23 GMT+03:00
JSONObject form_tarih2 = jObj.getJSONObject("form_tarih2");
String date = form_tarih2.getString("date");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
Date calculateDate = sdf.parse(date);
【问题讨论】:
-
我建议你不要使用
SimpleDateFormat和Date。这些类设计不佳且早已过时,尤其是前者,尤其是出了名的麻烦。而是使用来自java.time, the modern Java date and time API 的LocalDateTime和DateTimeFormatter。
标签: android datetime date-manipulation