package com.eactive.eai.common.usedate;

import java.io.Serializable;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * 1. 기능 : 업무 사용일자를 표현하는 Java Value Object 클래스. 
 * 2. 처리 개요 : 사용일자 정보를 정의한다. 
 * 3.
 * 주의사항
 *
 * @author :
 * @version : v 1.0.0
 * @see : 관련 기능을 참조
 * @since :
 */

public class UseDateControlVO implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String name;
	private Date startDate;
	private Date endDate;
	private boolean activate;
	
	DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");

	@Override
	public boolean equals(Object obj) {
		return name.equals(obj);
	}

	@Override
	public int hashCode() {
		return name.hashCode();
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public boolean isActivate() {
		return activate;
	}

	public void setActivate(boolean activate) {
		this.activate = activate;
	}
	
	public boolean isPass(long date) {
		if(startDate.getTime() <= date && date <= endDate.getTime()){
			return true;
		}else{
			return false;
		}
	}
	public String getStartDateString(){
		Instant instant = startDate.toInstant();
		LocalDateTime ldt = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
		return ldt.format(format);
	}
	
	public String getEndDateString(){
		Instant instant = endDate.toInstant();
		LocalDateTime ldt = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
		return ldt.format(format);
	}



}
