setStringToDataFormatter 변수명 수정 setStrToDataFormatter
This commit is contained in:
parent
1a1146bc0b
commit
b6d95f72f7
@ -3,6 +3,7 @@ package itn.com.cmm.util;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
@ -185,4 +186,21 @@ public final class DateUtils {
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
public static String setStrToDataFormatter(String str, String formatter) {
|
||||
|
||||
// 입력 문자열을 LocalDateTime으로 변환
|
||||
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
LocalDateTime dateTime = LocalDateTime.parse(str, inputFormatter);
|
||||
|
||||
// 원하는 출력 포맷 적용
|
||||
// DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("MM-dd HH:mm");
|
||||
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(formatter);
|
||||
String formattedDate = dateTime.format(outputFormatter);
|
||||
|
||||
return formattedDate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user