반응형 Language/Java16 [JAVA] 날짜 계산 (날짜 더하기, 날짜 빼기) 일하다가 만든 날짜 더하기 빼기 메서드이다. public String cal_date(String cal_day, String sign) { String today = util_dateinfo.get_today_ymdhis(); //오늘날짜 받기 String day = ""; try{ SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); Date date = format.parse(today); Calendar cal = Calendar.getInstance(); cal.setTime(date); int i_day = Integer.parseInt(cal_day); if("plus".equals(sign)) cal.add(Calendar.D.. 2022. 7. 15. [JAVA] Int to String, String to Int 형 변환 String to Int (String -> Int) String str = "1234"; int num = Integer.parseInt(str); Int to String (Int -> String) int num = 123; String str = Integer.toString(num); 2022. 7. 1. [JAVA] 에러 String index out of range 자바로 문자열을 일부분 끌어다 쓰고 싶을 때 자주 쓰는 기능인 substring()을 사용하다 보면 간혹 가다 발생하는 에러다. String index out of range : [숫자] 위와 같은 에러가 발생하는데 이유는 단순하다. 잘라야 할 문자열이 정해진 값보다 작아서 발생하는 에러다. String a = "abc"; String b = a.substring(0, 5); 위와 같은 코드를 작성하면 a의 길이는 3 b에서 자르고자 하는 길이는 0~5 고로 에러 발생. 해결 방법은 문자열의 길이를 미리 체크하거나 (if문을 이용해서) substring으로 잘라주는 값을 수정해주거나 받아오는 값을(위의 경우 a의 값) 잘라줘야 할 문자열 이상으로 반드시 들어오게 하면 된다. 2022. 5. 31. [JAVA] 구글 geocode 이용한 gps를 한글명 주소로 바꾸기 회사에서 프로젝트 진행중 gps 정보를 주소가 찍히게끔 변경해달라는 요구를 받았다. 그래서 알아보았다. 우선 google에 접속하여 api key를 발급받고 사용하고자 하는 api를 등록해야 한다. https://cloud.google.com/maps-platform/ Google Maps Platform - Location and Mapping Solutions Create real world and real time experiences for your customers with dynamic maps, routes & places APIs from Google Maps Platform’s location solutions. mapsplatform.google.com 위의 주소에서 좌측 상단의 프로젝.. 2022. 1. 4. 이전 1 2 3 4 다음 반응형