package com.munjaon.client.util; import com.munjaon.client.server.packet.Packet; import java.io.UnsupportedEncodingException; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; public final class MessageUtil { public static String getDateFormat(String format) { return LocalDateTime.now().format(DateTimeFormatter.ofPattern(format)); } /** * DateFormat : yyyyMMdd * @return */ public static String getDate() { return getDateFormat("yyyyMMdd"); } /** * DateFormat : yyyyMMddHHmmss * @return */ public static String getTime() { return getDateFormat("yyyyMMddHHmmss"); } public static String doNumber(String spell){ StringBuilder phoneNumber = new StringBuilder(); if (spell == null){ return phoneNumber.toString(); } spell = spell.trim(); int spell_Length = spell.length(); if (spell_Length < 1){ return phoneNumber.toString(); } for (int i=0; i 0){ headNum = srcNum.substring(0, index); tailNum = srcNum.substring((index + 1)); if (tailNum.isEmpty()) { tailNum = "0"; } if(tailNum.length() > digit){ tailNum = tailNum.substring(0, digit); } retNum = headNum + "." + tailNum; } } return retNum; } // 수신번호 체크하기 public static boolean checkPhone(String src) { if(src == null || src.trim().length() < 10) { return false; } return src.startsWith("0"); } // 문자열 공백 제거 public static String trim(String obj) { return StringUtil.trim(obj); } public static boolean isEmptyForMessage(String obj, boolean trimFlag) { if (trimFlag) return obj == null || obj.trim().isEmpty(); else return obj == null || obj.isEmpty(); } public static boolean isEmptyForMessage(String obj) { return isEmptyForMessage(obj, false); } public static boolean isOverByteForMessage(String obj, int limitCount, boolean trimFlag) throws UnsupportedEncodingException { if (isEmptyForMessage(obj, trimFlag)) { return true; } return obj.getBytes(Packet.AGENT_CHARACTER_SET).length > limitCount; } public static boolean isOverByteForMessage(String obj, int limitCount) throws UnsupportedEncodingException { return isOverByteForMessage(obj, limitCount, false); } }