package com.sifang.modules.flowpath.vo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeRange {
    private Date start;

    private Date end;

    public TimeRange(Date start, Date end) {
        this.start = start;
        this.end = end;
    }

    public boolean isOverlap(TimeRange other) {
        return this.end.after(other.start) && this.start.before(other.end);
    }

    public static void main(String[] args) throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date start1 = format.parse("2023-10-01");
        Date end1 = format.parse("2024-05-01");
        TimeRange time1 = new TimeRange(start1, end1);
        Date start2 = format.parse("2024-04-01");
        Date end2 = format.parse("2024-11-01");
        TimeRange time2 = new TimeRange(start2, end2);
        System.out.println("Time range 1: " + start1 + end1);
        System.out.println("Time range 2: " + start2 +  end2);
        if (time2.isOverlap(time1)) {
        System.out.println("The time ranges overlap.") ;
        }else {
                System.out.println("The time ranges do not overlap.") ;
        }
    }

}
