Android日历:下周的一天

Nav*_*yle 0 android date

我有这个方法解析一天和一个时间,问题是我需要得到下周的一天.

例:

我有这个日期和星期一,晚上10点,当前时间是星期一晚上11点,

当我解析parseTime("M","10:00 PM")它时,由于当前时间它返回过去的日期.

我想实现的是下周的晚上10点

public static Calendar parseTime(String day, String time) {

    String[] sepa_time_ampm = time.split(" ");

    String[] sepa_time_hr_mn = sepa_time_ampm[0].split(":");

    Calendar calendar = Calendar.getInstance();

    if (!isNumeric(day)) {
        calendar.set(Calendar.DAY_OF_WEEK, parseDay(day));
    }

    if(Integer.parseInt(sepa_time_hr_mn[0]) == 12) sepa_time_hr_mn[0] = "00";

    calendar.set(Calendar.HOUR, Integer.parseInt(sepa_time_hr_mn[0]));
    calendar.set(Calendar.MINUTE, Integer.parseInt(sepa_time_hr_mn[1]));
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);



    if (sepa_time_ampm[1].equals("AM")) {
        calendar.set(Calendar.AM_PM, Calendar.AM);
    } else {
        calendar.set(Calendar.AM_PM, Calendar.PM);
    }

    if((calendar.getTimeInMillis() - System.currentTimeMillis()) < 0) {
    //It is now in the past
    }

    return calendar;

}
Run Code Online (Sandbox Code Playgroud)

Tof*_*mad 6