자바 출력 시스템 날짜

940 단어
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class A5 {
public static void main(String[] args) {
	LocalDateTime ldt=LocalDateTime.now();
	DateTimeFormatter dtf=DateTimeFormatter.ofPattern("YYYY MM dd   HH mm ss ");
	System.out.println(ldt.format(dtf));
	
}}

두 번 째 방법:
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Zuoye2 {
	public static void main(String[] args) {
		Date date = new Date();
		SimpleDateFormat df = new SimpleDateFormat("YYYY   MM  dd    HH:mm:ss");
		System.out.println(df.format(new Date()));
		// %tj         
		String strDate = String.format("       %tj !", date);

		System.out.println(strDate);

		Calendar c = Calendar.getInstance();
		int i = c.get(Calendar.WEEK_OF_YEAR);
		System.out.println(" " + i + " ");

	}

}

 

좋은 웹페이지 즐겨찾기