ちょっとした問題で。クリックすると現在の時刻が取得され、特定の時間と分が追加される onClick があります。以下のコードは私が持っているもので、現在、データを別のアクティビティに送信して表示していますが、時間は変更されていません。
public void onClickHere (View v) {
String ti1me, ti2me, ti3me;
//carry out calculation
LocalTime localtime = new LocalTime();
LocalTime dt = new LocalTime(localtime);
//Add two hours and subtract 10 minutes
LocalTime twoHoursLater = dt.plusHours(2);
twoHoursLater = dt.minusMinutes(10);
//Add three hours and 9 minutes
LocalTime threeHoursLater = dt.plusHours(3);
threeHoursLater = dt.plusMinutes(9);
//Add five hours and subtract 8 minutes
LocalTime fiveHoursLater = dt.plusHours(5);
fiveHoursLater = dt.minusMinutes(8);
DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
ti1me = (twoHoursLater.toString(formatter));
ti2me = (threeHoursLater.toString(formatter));
ti3me = (fiveHoursLater.toString(formatter));
Intent i = new Intent(this, WakeUpMain.class);
i.putExtra("time1", ti1me);
i.putExtra("time2", ti2me);
i.putExtra("time3", ti3me);
startActivity(i);
}
ご覧のとおり、私は 3 回取得しようとしており、両方にさまざまな分と時間を追加しています。分は問題なく追加されますが、時間は現在の時刻のままであるか、分の追加方法とそれが次の時間。
これを入力すると 11:22 になり、アプリを実行してボタンをクリックすると、出力は次のようになります:
11:11
11:31
11:14
時間は変更ありません。これを修正する方法はありますか?時間は、たとえば時間が 11:05 の場合にのみ変更され、最初の時間は 10:55 と表示されます。
助けていただければ幸いです。本当に私を混乱させます。