본문 바로가기

date util14

Get Add Time(HHH:mm:ss) /** * Get Add Time(HHH:mm:ss) * * @param time1 * @param time2 * @return String(HHH:mm:ss) */public static String getAddTimes(String time1, String time2) { String[] time1Parts = time1.split(":"); long hours1 = Long.parseLong(time1Parts[0]); long minutes1 = Long.parseLong(time1Parts[1]); long seconds1 = Long.parseLong(time1Parts[2]); String[] time2Parts = time2.split(":"); long hours2 = Long.pars.. 2024. 11. 27.
Get Convert HHH:mm:ss to Second /** * Get Convert HHH:mm:ss to Second * * @param HHHmmss * @return int */public static int getConvToSeconds(String HHHmmss) { String[] parts = HHHmmss.split(":"); int hours = Integer.parseInt(parts[0]); int minutes = Integer.parseInt(parts[1]); int seconds = Integer.parseInt(parts[2]); return hours * 3600 + minutes * 60 + seconds;} 2024. 11. 27.
Get Convert Second to HHH:mm:ss /** * Get Convert Second to HHH:mm:ss * * @param second * @return String(HHH:mm:ss) */public static String getConvToHHHmmss(int second) { int hours = second / 3600; int minutes = (second % 3600) / 60; int seconds = second % 60; return String.format("%03d:%02d:%02d", hours, minutes, seconds);} 2024. 11. 27.
Get Days Between Count /** * Get Days Between Count * * @param contractFrom(yyyy-MM-dd) * @param contractTo(yyyy-MM-dd) * @return int */public static int getDaysBetween(String contractFrom, String contractTo) { LocalDate from = LocalDate.parse(contractFrom); LocalDate to = LocalDate.parse(contractTo); return (int) ChronoUnit.DAYS.between(from, to)+1;} 2024. 11. 27.
Get Date Now in String /** * Get Date Now in String(yyyyMMdd) * * @return String(yyyyMMdd) */public static String getDateNow01() { return LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE);}/** * Get Date Now in String(yyyy-MM-dd HH:mm:ss.SSS) * * @return String(yyyy-MM-dd HH:mm:ss.SSS) */public static String getDateNow02() { return LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SS.. 2024. 11. 27.
Start to Last Date Date 타입의 시작 날짜부터 종료 날짜까지 날짜들을 구하는 메소드*자세한 설명 생략  /** * Start to Last Date * @param {*} startDate(Date) * @param {*} lastDate(Date) * @returns YYYY-MM-dd */function getDatesStartToLast(startDate, lastDate) { if (!(startDate instanceof Date && lastDate instanceof Date)) return "Not Date Object"; var result = []; var curDate = startDate; while (curDate   ▷ 관련 글 Date FormaterDate 타입을 원하는.. 2023. 11. 14.
Date Formater Date 타입을 원하는 Format으로 변경하는 메소드*자세한 설명 생략  /** * Date Formater * * @param {*} date * @returns YYYYMMdd */function getFormatDate(date) { const YYYY = String(date.getFullYear()) const MM = String((date.getMonth() + 1) >= 10 ? (date.getMonth() + 1) : "0" + (date.getMonth() + 1)) const dd = String(date.getDate() >= 10 ? date.getDate() : "0" + date.getDate()) return YYYY + MM + dd}/** * .. 2023. 11. 14.
LocalTime AVG LocalTime 평균 구하기*parameter는 상황에 따라 변경해서 사용(LocalTime t1, LocalTime...ts)  /** * LocalTime AVG * * @param List * @return AVG LocalTime */public static LocalTime getLocalTimeAVG(List list) { LocalTime result = LocalTime.of(0, 0, 0); if (!list.isEmpty()) { long nanoSum = 0L; for (LocalTime time : list) { nanoSum += time.toNanoOfDay(); } result = LocalTi.. 2023. 9. 21.
String to LocalTime String time format은 상황에 따라 변경해서 사용  /*** String(HHmmss) to LocalTime* * @param String(HHmmss)* @return LocalTime(HH:mm:ss)*/public static LocalTime getStrLocalTime(String str) { return LocalTime.parse(str, DateTimeFormatter.ofPattern("HHmmss"));} 2023. 9. 21.
728x90
728x90