简体   繁体   中英

How to change a date in Java Swing

I have worked on a loan installment calculator in Java swing. How do I get 6 month dates if I make 6 month installments. I want this scenario in Java swing. How do I get 6, 8, 10 month dates in loop in Java swing?

在此处输入图片说明

for (int i = 0; i < date.length; i++) { // cycle #1: over all initialized dates
    for (int j = 0; j < 40; i++) {      // cycle #2: 40 repeats for each date
        date[i].nextDay();
        System.out.print("Incremented Date:" + date[i].toString());
    }

It's not really clear to me, but you may mean something like the following?

    LocalDate startDate = LocalDate.of(2019, Month.FEBRUARY, 1);
    int months = 10;

    LocalDate currentDate = startDate;
    for (int i = 0; i < months; i++) {
        System.out.println(currentDate);
        currentDate = currentDate.plusMonths(1);
    }

Output:

 2019-02-01 2019-03-01 2019-04-01 2019-05-01 2019-06-01 2019-07-01 2019-08-01 2019-09-01 2019-10-01 2019-11-01

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM