setStringToDataFormatter 변수명 수정 setStrToDataFormatter
@b6d95f72f7dc1c3b832df6454c429cdec0005b1b
--- src/main/java/itn/com/cmm/util/DateUtils.java
+++ src/main/java/itn/com/cmm/util/DateUtils.java
... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 |
import java.text.ParseException; |
| 4 | 4 |
import java.text.SimpleDateFormat; |
| 5 | 5 |
import java.time.LocalDate; |
| 6 |
+import java.time.LocalDateTime; |
|
| 6 | 7 |
import java.time.format.DateTimeFormatter; |
| 7 | 8 |
import java.time.temporal.ChronoUnit; |
| 8 | 9 |
import java.util.Date; |
... | ... | @@ -185,4 +186,21 @@ |
| 185 | 186 |
|
| 186 | 187 |
return isValid; |
| 187 | 188 |
} |
| 189 |
+ |
|
| 190 |
+ public static String setStrToDataFormatter(String str, String formatter) {
|
|
| 191 |
+ |
|
| 192 |
+ // 입력 문자열을 LocalDateTime으로 변환 |
|
| 193 |
+ DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
| 194 |
+ LocalDateTime dateTime = LocalDateTime.parse(str, inputFormatter); |
|
| 195 |
+ |
|
| 196 |
+ // 원하는 출력 포맷 적용 |
|
| 197 |
+// DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("MM-dd HH:mm");
|
|
| 198 |
+ DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(formatter); |
|
| 199 |
+ String formattedDate = dateTime.format(outputFormatter); |
|
| 200 |
+ |
|
| 201 |
+ return formattedDate; |
|
| 202 |
+ } |
|
| 203 |
+ |
|
| 204 |
+ |
|
| 205 |
+ |
|
| 188 | 206 |
} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?