Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

chapter10 : Date_SimpleDateFormat 본문

JAVA/chapter20_api

chapter10 : Date_SimpleDateFormat

GAWON 2023. 5. 30. 18:24
package org.joonzis.ex;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Ex10_Date_SimpleDateFormat {
	public static void main(String[] args) {
		
		Date now = new Date();	// Date와 SimpleDateFormat은 짝꿍으로 쓰자
		System.out.println(now);
		
		// SimpleDateFormat
		// 년 : yy, yyyy
		// 월 : M, MM
		// 일 : d, dd
		// 요일 : E
		// 오전오후 : a
		// 시 : hh(12시각제), HH(24시각제)
		// 분 : mm
		// 초 : ss
		
		SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
		SimpleDateFormat format2 = new SimpleDateFormat("yy/MM/dd");
		SimpleDateFormat format3 = new SimpleDateFormat("yyyy년 MM월 dd일 E요일");
		SimpleDateFormat format4 = new SimpleDateFormat("M월 W번 째 주 d번째 날, F번 째 E요일");
		
		System.out.println(format1.format(now));
		System.out.println(format2.format(now));
		System.out.println(format3.format(now));
		System.out.println(format4.format(now));
		
		
	}
}

'JAVA > chapter20_api' 카테고리의 다른 글

chapter12 : Dday  (0) 2023.05.30
chapter11 : Calendar_Date  (0) 2023.05.30
chapter09 : Calendar  (0) 2023.05.30
chapter08 : Big_number  (0) 2023.05.30
chapter07 : Wrapper  (0) 2023.05.30