vnfvj2018. 9. 13. 16:49
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())));
'생존기술_IT > JAVA' 카테고리의 다른 글
[JAVA] 루프로 돌려서 GET,POST로 들어온 파라메터들 나열하기.. (0) | 2020.10.04 |
---|---|
[JSP/PHP] JSP vs PHP 서버변수 모음 (0) | 2020.10.04 |
[JAVA] request.getServerName() + @ - get서버관련info (0) | 2020.10.04 |
[JAVA] jsp:include 와 <%@ include%> (0) | 2020.09.21 |
[JAVA] execute / executeQuery / executeUpdate (0) | 2020.09.14 |