package com.nisum.myteam.utils;

import lombok.extern.slf4j.Slf4j;

import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Calendar;
import java.util.Date;

@Slf4j
public class MyTeamDateUtils {

    public static Date getYesterdayDate() {
        final Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, -1);
        return cal.getTime();
    }
    public static LocalDate convertUtilDateToLocalDate(Date dateToConvert) {
        return dateToConvert.toInstant()
                .atZone(ZoneId.systemDefault())
                .toLocalDate();
    }


    public static Date getDayLessThanDate(Date date)
    {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.DATE, -1);
        Date yesterday = calendar.getTime();
        log.info("Day before Date is::"+yesterday);
        return yesterday;
    }

    //public static void main(String[] args)
    //{
       // MyTeamDateUtils.getDayLessThanDate(new Date());
   // }

}
