package hello;
import java.time.*;
public class time_package {
public static void main(String[] args) {
LocalDateTime dateTime = LocalDateTime.of(2015,12,31,12,34,56);
System.out.print(dateTime);
}
}
출력결과 : 2015-12-31T12:34:56
package hello;
import java.util.*;
public class calendar {
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) +1;
//System.out.println("Current time is :" + cal.getTime());
System.out.println(" "+year + "년"+ month + "월");
System.out.println(" SUN MON THU WEN THR FRI SAT");
Calendar sDay = Calendar.getInstance();
Calendar eDay = Calendar.getInstance();
sDay.set(year, month-1,1);
eDay.set(year, month,1);
eDay.add(Calendar.DATE, -1);
int START_DAY_OF_WEEK = 0;
int END_DAY = 0;
START_DAY_OF_WEEK = sDay.get(Calendar.DAY_OF_WEEK);
END_DAY = eDay.get(Calendar.DATE);
for (int i = 1; i< START_DAY_OF_WEEK; i++) {
System.out.print(" ");
}
for (int i =1, n = START_DAY_OF_WEEK; i<=END_DAY; i++, n++) {
System.out.print((i<10)?" " + i :" "+ i);
if(n%7 ==0) System.out.println();
}
}
}
출력결과 :
'Study > Java' 카테고리의 다른 글
Collection Framwork 1.3 LinkedList (0) | 2018.03.05 |
---|---|
Collection Framework 1.2 ArrayList (0) | 2018.03.05 |
Collection Framework 1.7 Comparator, Comparable (0) | 2018.02.26 |
Collection Framework 1.6 Arrays (2) | 2018.02.26 |
Collection Framework 1.5 lterator, Listlterator, Enumeration (0) | 2018.02.26 |