JAVA (360) 썸네일형 리스트형 SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" dependency 추가 후 rebuild - restart org.slf4j slf4j-api ${org.slf4j-version} org.slf4j jcl-over-slf4j ${org.slf4j-version} runtime org.slf4j slf4j-log4j12 ${org.slf4j-version} runtime MessageFormat, 문자열을 정의하고 {0} index에 채워넣다 MessageFormat 정해진 양식에 맞게 데이터를 출력할 수 있도록 도와준다. 양식을 미리 작성하고 다수의 데이터를 같은 양식으로 출력할때 사용하면 좋다. import java.text.MessageFormat; public class MessageFormatExample { public static void main(String[] args) { // 템플릿 문자열 정의 String template = "Hello, {0}! Today is {1}."; // MessageFormat을 사용하여 변수를 채워넣습니다. String formattedMessage = MessageFormat.format(template, "John", "Monday"); // 결과 출력 System.out.println(.. ChoiceFormat, limits와 grades를 설정해 등급추출하기 ChoiceFormat 특정범위에 속하는 값을 문자열로 변환할 수 있다. import java.text.ChoiceFormat; public class GradeExample { public static void main(String[] args) { // 등급 범위와 해당하는 문자열을 정의합니다. double[] limits = {60, 70, 80, 90}; String[] grades = {"F", "D", "C", "B", "A"}; // ChoiceFormat을 생성합니다. ChoiceFormat choiceFormat = new ChoiceFormat(limits, grades); // 특정 점수에 대한 등급을 확인합니다. double[] scores = {55, 67, 78, 88, 92};.. SimpleDateFormat, Date와 Calendar보다 쉽게 날짜 형식 지정하기 SimpleDateFormat Date와 Calendar만으로 날짜 데이터를 출력하는 것은 불편하다. SimpleDateFormat를 이용시 여러 문제들이 간단히 해결된다. 편의상 전체를 통합한 예시를 첨부했으나 사용시에는 선택적으로 사용하도록 하자. G 연대 (BC, AD) Y 년도 M 월 MMM일경우 JAN, MMMM일경우 JANUARY D 일 w 년의 몇번째 주 W 월의 몇번째 주 D 월에서 현재 날짜의 주수 d 요일 F 해당날짜가 속한 주의 첫번째 일 E 오전 혹은 오후 a 오전오후 H 0부터 24시간 k 1부터 24시간 K 1부터 12시간 h 1부터 12시간 m 분 s초 S 밀리초 z 일반적인 시간대 Z GMT/UTC로부터의 시간대 ' 리터럴 취급 import java.text.SimpleDat.. DecimalFormat, 숫자데이터를 다양한 형식으로 표현하다 우선 예시코드로 우선 이해해보자. 패턴 아래의 코드를 보면 1234567.89란 숫자를 #,##0.00형식으로 바꾸기로 지정하고 출력했다. import java.text.DecimalFormat; public class DecimalFormatExample { public static void main(String[] args) { double number = 1234567.89; // 패턴 정의: #는 숫자가 없으면 표시하지 않음, 0은 반드시 표시 DecimalFormat decimalFormat = new DecimalFormat("#,##0.00"); // 숫자를 형식화하여 문자열로 변환 String formattedNumber = decimalFormat.format(number); System.. Calendar와 Date, 이를 이용한 날짜/ 일수 출력하기 오래전부터 제공되던 Date클래스를 보완하기 위해 Calendar 클래스가 등장. Calendar와 GregorianCalendar GregorianCalendar는 Calendar를 상속받아 구현한 전세계 공통 그레고리력에 맞게 구현한것. // Calendar를 사용하여 현재 날짜 및 시간 가져오기 Calendar calendar = Calendar.getInstance(); System.out.println("Calendar - 현재 날짜 및 시간: " + calendar.getTime()); //Calendar - 현재 날짜 및 시간: Mon Dec 27 12:34:56 UTC 2023 GregorianCalendar gregorianCalendar = new GregorianCalendar(); .. @Transactional Spring 트랜젝션, 실패시 되돌리다 @Transactional 하나의 table이라면 관련없으나 여러개의 table을 작성/수정시에는 중간에 에러날경우 롤백, 처음으로 되돌려야 한다. Spring에는 애너테이션으로 트랜젝션기능을 제공한다. @Transactional controller에서는 service를 실행하고 @RequestMapping(value = "/manpower_edit", method = { RequestMethod.POST }) public ResponseEntity manpowerEdit(@ModelAttribute MpVO mpVO, HttpServletRequest req, HttpServletResponse res) { //System.out.println("전체 form정보: " + mpVO); //System... java.math.BigDecimal, double타입보다 오차가 없도록 2진수로 변환해 수를 다루다 double타입으로 표현할 수 있는 값은 범위가 넓으나 정밀도가 최대 13자리밖에 되지않아 오차를 피할 수 없다. https://standout.tistory.com/22 숫자의 종류, 실수 무리수 유리수 정수 자연수 간단히 예시로 정리하자. 실수 floating point number 3.14 무리수 irrational number 𝝅 유리수 rational number ⅛ 정수 integer ... -2, -1, 0, 1, 2 … 자연수 natural number 1, 2, 3, 4, 5, 6 … 실수, floating point 3141592란 수에 standout.tistory.com https://standout.tistory.com/56 자바 기본타입 (bsilfdcb) 외워보자. bsil f.. 이전 1 ··· 13 14 15 16 17 18 19 ··· 45 다음