package calendar;
import java.util.Calendar;
public class ScheduleModel {
private final long MILLIS_IN_DAY = 1000 * 60 * 60 * 24;
private int year;
private int month;
private int date;
private String content;
// CONSTRUCTOR
public ScheduleModel(int year, int month, int date, String content) {
this.year = year;
this.month = month;
this.date = date;
this.content = content;
}
// CONSTRUCTOR
public ScheduleModel(String line) {
int index = line.indexOf("[");
String[] date = line.substring(index + 1, index + 11).split("-");
System.out.println(date[0] + "/" + date[1] + "/" + date[2]);
String con = line.substring(index + 13);
this.year = Integer.parseInt(date[0]);
this.month = Integer.parseInt(date[1]);
this.date = Integer.parseInt(date[2]);
this.content = con;
}
// Getter / Setter
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
public int getDate() {
return date;
}
public void setDate(int date) {
this.date = date;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String toDdayString(Calendar today) {
long todayTime = today.getTimeInMillis();
Calendar cal = Calendar.getInstance();
cal.set(year, month - 1, date);
long modelTime = cal.getTimeInMillis();
String dday = "D";
if (modelTime > todayTime) {
// D-()
int temp = (int) Math.floor((modelTime - todayTime) / MILLIS_IN_DAY);
dday += ("-" + temp);
}
else if (modelTime < todayTime) {
// D+()
int temp = (int) Math.floor((todayTime - modelTime) / MILLIS_IN_DAY);
dday += ("+" + temp);
}
else {
// D-DAY
dday += "-DAY";
}
return String.format("(%s) [d-d-d] %s", dday, year, month, date, content);
}
@Override
public String toString() {
return String.format("[d-d-d] %s", year, month, date, content);
}
@Override
public boolean equals(Object comparer) {
ScheduleModel model = (ScheduleModel)comparer;
return this.year == model.year &&
this.month == model.month &&
this.date == model.date &&
this.content.equals(model.content);
}
}
캘린더 프로그램에 d-day기능을 넣은 부분 관련인데 java 생 초짜이다 보니 해석이 안되네요
해석좀 해주실 수 있는분 안계신가요.. hwich@icloud.com 이쪽으로 보내주시면 기프티콘이라도 보내드리겠습니다.ㅠㅠ
계신가요->계시나요 (계시다는 동사라 형용사 뒤에 쓰이는 어미 -ㄴ가(요)를 붙인 계신가요는 적절하지 않고, 주로 동사 뒤에 쓰이는 어미 -나(요)를 붙인 계시나요가 적절함) [리듬 맞춤법 봇♬]
스케쥴 모델 - 입력받은 년 월 일 세팅하는 클래스 인자 유형에 따라 생성자 오버로드되고 그 다음 getset함수를 통해 해당 안의 년 월 일 설정 후 get으로 불러올 수 있음 디데이스트링은 캘린더 객체 2개 비교를 통해서 해당 날짜가 오늘보다 크거나 같거나 작거나의 경웨 따라 if조건으로 나눠지고 출력됩니다.
경웨 -> 경우에
도시백랑 // 감사합니다 이제 조금 이해가 되네요!!