■ 개발 정리/JAVA
-
Java - PKIX path building failed 에러 해결■ 개발 정리/JAVA 2022. 9. 2. 09:19
JAVA를 통해 https 통신을 할 때 접근 요청에 대한 인증이 되지 않아 PKIX path building failed 에러가 발생한다. 이에 해결 방안은 2가지가 있다. 1. 인증서가 있을 경우 인증서를 $JAVA_HOME/lib/security/cacerts (Java의 CAfile 저장소)에 추가해준다. 2. 인증서가 없는 경우 코드 상에서 처리 한다. import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; public void cunnectHttps() throws Exception { ..
-
JAVA 대문자 to 소문자, 소문자 to 대문자■ 개발 정리/JAVA 2020. 12. 17. 11:30
to 소문자 tolowerCase() 사용 to 대문자 toUpperCase() 사용 String input = ""; String output = ""; for(int i = 0; i < input.length(); i++) { char temp = input.charAt(i); // to 소문자 output += input.valueOf(tmp).toLowerCase(); // to 대문자 // output += input.valueOf(tmp).toUpperCase(); } System.out.println(output);
-
날짜 시간 LocalDate, LocalTime, LocalDateTime, OffsetDateTime■ 개발 정리/JAVA 2019. 5. 22. 14:23
- 사용법 LocalDate currentDate = LocalDate.now(); // 시스템의 현재 날짜 정보 2018-07-26 LocalDate myDate = LocalDate.of(int year, int month, int datOfMonth); //년,월,일 getYear(); getMonth(); (Month 열거값나옴 JANUARY, FEBRUARY) getMonthValue(); 월(1,2,3,...) getDayOfYear(); 년의 몇 번째 일 getDayOfMonth(); 월의 몇번째 일 getDayOfWeek(); 요일(MONDAY, TUESDAY,...) isLeapYear(); 윤년여부 LocalTime currentTime = LocalTime.now(); // 시스템의 ..
-
[JAVA] Integer 비교■ 개발 정리/JAVA 2018. 12. 19. 15:12
Integer 같은 클래스를 비교할때 (Long 도 같음) 다음과 같이 하면 레퍼런스를 비교하는 연산이다 Integer intA = new Integer(10);Integer intB = new Integer(10); if( int A == intB ) 위의 결과는 false 이다 Integer 의 값을 비교하고 싶으면 equals() 나 intValue() 매서드 (Long 일 경우 longValue() )를 사용해야한다 Integer intA = new Integer(10);Integer intB = new Integer(10); if( intA.equals(intB) )또는if( intA.intValue() == intB.intValue() )
-
[JAVA] 어제(전날)날짜 구하기■ 개발 정리/JAVA 2018. 11. 9. 11:32
전날 날짜를 구할때 String 인 날짜를 int로 바꿔서 -1하면~~~!!!!안된다...날짜가 1일이면 전날이면 0일인가..그래서 Calendar 클래스를 활용한 날짜 구하는 방식이 필요하다. ex)// 1. 날짜 표시 formatSimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); // 2. 오늘날짜 Data 클래스로 구하기(기준날짜가 오늘이 아니면 생략가능)Date today = new Date();// 3. 오늘날짜 format에 맞춰서 String 으로 변경(기준날짜가 오늘이 아니면 생략가능)String date = formatter.format(today);// 4. 기준이 되는 날짜(format에 맞춘)Date setDate = ..
-
BigDecimal 사칙연산 (더하기, 빼기, 곱하기, 나누기) , 소수점처리(올림, 버림, 반올림) , 실수비교 compareTo()함수■ 개발 정리/JAVA 2018. 8. 30. 13:53
BigDecimal 사칙연산 (더하기, 빼기, 곱하기, 나누기) , 소수점처리(올림, 버림, 반올림) , 실수비교 compareTo()함수 1. 사칙연산 및 소수점 처리 ( BigDecimal 사용 ) BigDecimal bdcl1 = new BigDecimal("123.123"); BigDecimal bdcl2 = new BigDecimal("456.456"); 더하기 : bdcl1.add(bdcl2); 빼기 : bdcl1.subtract(bdcl2); 곱하기 : bdcl1.multiply(bdcl2); 나누기 : 올림 - bdcl1.divide(bdcl2 , 2(소수점자리수), RoundingMode.UP); 버림 - bdcl1.divide(bdcl2 , 4, RoundingMode.DOWN); 반올..