| Line 22... |
Line 22... |
| 22 |
public class StringUtils {
|
22 |
public class StringUtils {
|
| 23 |
|
23 |
|
| 24 |
private static ObjectMapper objectMapper = new ObjectMapper();
|
24 |
private static ObjectMapper objectMapper = new ObjectMapper();
|
| 25 |
|
25 |
|
| 26 |
private static final Logger LOGGER = LoggerFactory.getLogger(StringUtils.class);
|
26 |
private static final Logger LOGGER = LoggerFactory.getLogger(StringUtils.class);
|
| 27 |
private static final String DATE_PATTERN = "MM/dd/yyyy";
|
27 |
private static final String DATE_PATTERN = "dd/MM/yyyy";
|
| 28 |
private static final String DATE_PATTERN_HYPHENATED = "yyyy-MM-dd";
|
28 |
private static final String DATE_PATTERN_HYPHENATED = "yyyy-MM-dd";
|
| 29 |
private StringUtils(){
|
29 |
private StringUtils(){
|
| 30 |
|
30 |
|
| 31 |
}
|
31 |
}
|
| 32 |
public static final LocalDate toDate(String dateString)throws DateTimeParseException{
|
32 |
public static final LocalDate toDate(String dateString)throws DateTimeParseException{
|
| 33 |
LOGGER.info("Converting dateString [{}] with pattern[{}]", dateString, DATE_PATTERN);
|
33 |
LOGGER.info("Converting dateString [{}] with pattern[{}]", dateString, DATE_PATTERN);
|
| - |
|
34 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DATE_PATTERN);
|
| 34 |
return LocalDate.parse(dateString);
|
35 |
return LocalDate.parse(dateString, dateTimeFormatter);
|
| 35 |
}
|
36 |
}
|
| 36 |
|
37 |
|
| 37 |
public static final LocalDate fromHypendatedDate(String dateString)throws DateTimeParseException{
|
38 |
public static final LocalDate fromHypendatedDate(String dateString)throws DateTimeParseException{
|
| 38 |
LOGGER.info("Converting dateString [{}] with pattern[{}]", dateString, DATE_PATTERN_HYPHENATED);
|
39 |
LOGGER.info("Converting dateString [{}] with pattern[{}]", dateString, DATE_PATTERN_HYPHENATED);
|
| - |
|
40 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DATE_PATTERN_HYPHENATED);
|
| 39 |
return LocalDate.parse(dateString);
|
41 |
return LocalDate.parse(dateString, dateTimeFormatter);
|
| 40 |
}
|
42 |
}
|
| 41 |
|
43 |
|
| 42 |
public static final LocalTime toTime(String timeString) throws DateTimeParseException{
|
44 |
public static final LocalTime toTime(String timeString) throws DateTimeParseException{
|
| 43 |
return LocalTime.parse(timeString);
|
45 |
return LocalTime.parse(timeString);
|
| 44 |
}
|
46 |
}
|