목록date (2)
개발 무지렁이

Date 객체와 SimpleDateFormat Date now = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy,MM.dd HH:mm:ss"); sdf.format(now) Date() 생성자는 컴퓨터의 현재 날짜를 읽어 Date객체로 만든다. public class DateExample { public static void main(String[] args) { Date now = new Date(); String strNow = now.toString(); System.out.println(strNow); //Tue Aug 09 00:55:51 KST 2023 SimpleDateFormat sdf = new SimpleDateFormat..

Date 객체와 SimpleDateFormat 객체 [Util.java] new Date(), 현재 날짜와 시간이 저장된 Date 객체 반환 원하는 포맷 패턴을 파라미터로 넘겨 SimpleDateFormat 생성자 생성 SimpleDateFormat의 format 메서드 이용 public class Util { public static class date { public static String getCurrentDateFormatted(String pattern) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); return simpleDateFormat.format(new Date()); } } } ❓ 내부클래스를 사용하는 이유..