하지의 코딩일지/JAVA TEST
달력 생성기 (테스트)
하지마지
2023. 7. 7. 15:09
728x90
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
import java.time.LocalDate;
import java.util.Scanner;
public class JavaStudy05 {
public JavaStudy05() {
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("년도를 입력하세요 : ");
int year = sc.nextInt();
System.out.print("월을 입력하세요 : ");
int month = sc.nextInt();
LocalDate date = LocalDate.of(year, month, 1);
LocalDate endDate = date.withDayOfMonth(date.lengthOfMonth());
System.out.println("---------[" + year + "년 " + month + "월]---------");
System.out.println(" 일 월 화 수 목 금 토");
int dayOfWeek = date.getDayOfWeek().getValue();
for(int i = 1; i <= endDate.getDayOfMonth(); ++i) {
if (i == 1) {
for(int j = 1; j < dayOfWeek; ++j) {
System.out.print(" ");
}
}
if (i < 10) {
System.out.print(" ");
}
System.out.print(" " + i + " ");
if (dayOfWeek % 7 == 0) {
System.out.println();
}
++dayOfWeek;
}
System.out.println("-----------------------------");
}
}
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
import java.time.LocalDate;
import java.util.Scanner;
public class JavaStudy05 {
public JavaStudy05() {
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("년도를 입력하세요 : ");
int year = sc.nextInt();
System.out.print("월을 입력하세요 : ");
int month = sc.nextInt();
LocalDate date = LocalDate.of(year, month, 1);
LocalDate endDate = date.withDayOfMonth(date.lengthOfMonth());
System.out.println("---------[" + year + "년 " + month + "월]---------");
System.out.println(" 일 월 화 수 목 금 토");
int dayOfWeek = date.getDayOfWeek().getValue();
for(int i = 1; i <= endDate.getDayOfMonth(); ++i) {
if (i == 1) {
for(int j = 1; j < dayOfWeek; ++j) {
System.out.print(" ");
}
}
if (i < 10) {
System.out.print(" ");
}
System.out.print(" " + i + " ");
if (dayOfWeek % 7 == 0) {
System.out.println();
}
++dayOfWeek;
}
System.out.println("-----------------------------");
}
}
728x90