1. 문자열 날짜를 Timestamp 변환 및 검증

java.sql.Timestamp timestamp_1 = java.sql.Timestamp.valueOf("2018-09-21 10:53:00.0");

System.out.format("timestamp : %s\r", timestamp_1.getTime());

System.out.format("date : %s\r\r", new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(timestamp_1));



2. Java 로컬 날짜를 Timestamp 변환 및 검증

java.sql.Timestamp timestamp_2 = java.sql.Timestamp.valueOf(LocalDateTime.now());

System.out.format("timestamp : %s\r", timestamp_2.getTime());

java.sql.Date date = new java.sql.Date(timestamp_2.getTime());

System.out.format("date : %s\r\r", new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(date));



3. 문자열 Timestamp 를 객체화, 변환 및 검증

java.sql.Timestamp timestamp_3 = new java.sql.Timestamp(Long.parseLong("1537495373964"));

System.out.format("timestamp : %s\r", timestamp_3.getTime());

System.out.format("date : %s", new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new java.sql.Date(timestamp_2.getTime())));


블로그 이미지

촌놈 개발자 일기

개발자로서 살아가는 느낌과 정보를 공유 합니다

,