목록util (3)
개발 무지렁이

URLEncoder 클래스 [Util.java] public class Util { public static class url { public static String encode(String str) { try { return URLEncoder.encode(str, "UTF-8"); } catch (UnsupportedEncodingException e) { return str; } } } } ❓ 내부 클래스를 사용하는 이유 : 내부 클래스는 딱히 외부에서 독자적으로 쓰일 일이 없으면 내부 클래스로 만들어주는 것이 좋다. => 코드의 의도를 명시적으로 표현

[article/write.html] 글쓰기 제목 내용 본문이미지 [Util.java] public class Util { public static class date { public static String getCurrentDateFormatted(String pattern) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); return simpleDateFormat.format(new Date()); } } public static class file { public static String getExt(String filename) { return Optional.ofNullable(filename) .filter(f -> ..

Date 객체와 SimpleDateFormat 객체 [Util.java] new Date(), 현재 날짜와 시간이 저장된 Date 객체 반환 원하는 포맷 패턴을 파라미터로 넘겨 SimpleDateFormat 생성자 생성 SimpleDateFormat의 format 메서드 이용 public class Util { public static class date { public static String getCurrentDateFormatted(String pattern) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); return simpleDateFormat.format(new Date()); } } } ❓ 내부클래스를 사용하는 이유..