计算日期后 3 个月 - Android

ber*_*new 1 datetime android date-manipulation

我想计算从数据库中提取日期后的 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);
Run Code Online (Sandbox Code Playgroud)

Har*_*der 5

尝试这个:

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);

final Calendar calendar = Calendar.getInstance();
calendar.setTime(calculateDate);
calendar.add(Calendar.MONTH,4);
Run Code Online (Sandbox Code Playgroud)

您可以根据需要添加/子日、月、年等Calendar