728x90
๋ฐ˜์‘ํ˜•

์ „์ฒด ๊ธ€ 1101

[JAVA] ๊ธˆ์•ก(BigDecimal)์„ ํ•œ๊ธ€๋กœ ๋ณ€ํ™˜ํ•˜๊ธฐ

import java.math.BigDecimal;public class NumberToKorean { public static String convertToKorean(BigDecimal amount) { if (amount == null || amount.compareTo(BigDecimal.ZERO) == 0) { return "์˜"; } final String[] KOREAN_NUMBERS = { "", "์ผ", "์ด", "์‚ผ", "์‚ฌ", "์˜ค", "์œก", "์น ", "ํŒ”", "๊ตฌ" }; final String[] UNITS = { "", "์‹ญ", "๋ฐฑ", "์ฒœ" }; final String[] LARGE_UNI..

JAVA 2024.11.20

์‹ฑ๊ธ€ ์‚ฌ์ธ ์˜จ(Single Sign-On, SSO)

์‹ฑ๊ธ€ ์‚ฌ์ธ ์˜จ(Single Sign-On, SSO)์€ ์‚ฌ์šฉ์ž๊ฐ€ ๋›ฐ์–ด๋‚œ ์ธ์ฆ ํ”„๋กœ์„ธ์Šค๋ฅผ ํ†ตํ•ด ๋‹ค์–‘ํ•œ ์‹œ์Šคํ…œ์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ด์ฃผ๋Š” ์ง„์ •ํ•œ ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค. ๋ณธ ์„œ๋น„์Šค๋Š” ์‚ฌ์šฉ์ž ๊ฐ ์„œ๋น„์Šค๋งˆ๋‹ค ๋ณ„๋„์˜ ๋กœ๊ทธ์ธ ์ ˆ์ฐจ๋ฅผ ์ œ๊ณตํ•ด์•ผ ํ•˜๋ฉฐ, ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ณด์•ˆ ์—ฐ๊ฒฐ ์„œ๋น„์Šค๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.SSO ์ž‘๋™ ๋ฐฉ์‹์‚ฌ์šฉ์ž ์ธ์ฆ : ์‚ฌ์šฉ์ž๊ฐ€ ์ฒ˜์Œ ๋กœ๊ทธ์ธํ•˜๋ฉด SSO ์‹œ์Šคํ…œ์ด ์ธ์ฆ์„ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.์ธ์ฆ ์™„๋ฃŒ : SSO ์‹œ์Šคํ…œ์ด ์ธ์ฆ์„ ๋ฐ›์€ ํ›„ ์ธ์ฆ(์˜ˆ: SAML, OAuth, JWT)์„ ์‚ฌ์šฉ์ž์—๊ฒŒ ์ธ์ฆํ•ฉ๋‹ˆ๋‹ค.์˜๋ฏธ ์ „๋‹ฌ : ์‚ฌ์šฉ์ž๋Š” ์ด ์˜๋ฏธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ ์„œ๋น„์Šค์— ์ ‘๊ทผํ•˜๋ฉฐ, ์„œ๋น„์Šค๋Š” ์˜๋„๋ฅผ ์ธ์ •ํ•ด ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.์ž๋™ ๋กœ๊ทธ์ธ : ์‚ฌ์šฉ์ž๊ฐ€ ๋‹ค๋ฅธ ์‹œ์Šคํ…œ์— ์ ‘๊ทผํ•  ๋•Œ ๋™๋“ฑํ•œ ์ธ์ฆ ์ •๋ณด๋ฅผ ์‚ฌ์šฉํ•˜๋ฏ€๋กœ ์ถ”๊ฐ€ ๋กœ๊ทธ์ธ ์ ˆ์ฐจ๊ฐ€ ํ•„์š”ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.SSO์˜ ์ฃผ์š” ํ”„..

IT์ง€์‹ 2024.11.19

[JAVA] ์ด๋ฏธ์ง€ ํŒŒ์ผ์„ Base64๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ์ „์†ก

์ด๋ฏธ์ง€ ํŒŒ์ผ์„ Base64๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•˜๋Š” ๋ฐฉ์‹์€ ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณ€ํ™˜ํ•˜์—ฌ ์ „๋‹ฌํ•˜๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค.import java.nio.file.Files;import java.nio.file.Paths;import java.util.Base64;public class ImageBase64Encoder { public static void main(String[] args) { try { // ์ด๋ฏธ์ง€ ํŒŒ์ผ ๊ฒฝ๋กœ String imagePath = "path/to/your/image.jpg"; // ์ด๋ฏธ์ง€ ํŒŒ์ผ ์ฝ๊ธฐ byte[] imageBytes = Files.readAllBytes(Pat..

JAVA 2024.11.18

[JAVA] Stream์œผ๋กœ List ์ค‘๋ณต ์ œ๊ฑฐ

Stream์˜ distinct()๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๊ฐ„๋‹จํ•˜๊ฒŒ ๊ฐ„๋‹จํ•œ ์ œ๊ฑฐ๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.import java.util.*;import java.util.stream.*;public class RemoveDuplicatesExample { public static void main(String[] args) { List list = Arrays.asList("apple", "banana", "apple", "orange"); // Stream์œผ๋กœ ์ค‘๋ณต ์ œ๊ฑฐ List uniqueList = list.stream() .distinct() ...

JAVA 2024.11.17

[JAVA] ๋‚ ์งœ๋ฐ์ดํ„ฐ ๋…„์›”์ผ๋กœ ๋ณ€ํ™˜ํ•˜๊ธฐ

import java.time.LocalDate;import java.time.format.DateTimeFormatter;public class DateFormatExample { public static void main(String[] args) { // ์ž…๋ ฅ๋œ 8์ž๋ฆฌ ์ˆซ์ž ๋ฌธ์ž์—ด String inputDate = "20241118"; // ์˜ˆ: 2024๋…„ 11์›” 18์ผ // ์›๋ž˜ ํ˜•์‹์˜ DateTimeFormatter ์ •์˜ DateTimeFormatter originalFormatter = DateTimeFormatter.ofPattern("yyyyMMdd"); // ์›ํ•˜๋Š” ์ถœ๋ ฅ ํ˜•์‹ ์ •์˜ (๋…„์›”์ผ) DateTimeF..

JAVA 2024.11.15

[SQL] ๋ฌธ์ž์—ด ๋ฆฌํ„ฐ๋Ÿด์— ์ž‘์€ ๋”ฐ์˜ดํ‘œ๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๋Š” ์ด์œ 

SQL์—์„œ ๋ฌธ์ž์—ด ๋ฆฌํ„ฐ๋Ÿด์€ **์ž‘์€ ์ธ์šฉ( ')**๋กœ ๊ฐ์‹ธ์•ผ ํ•ฉ๋‹ˆ๋‹ค. SQL ํ‘œ์ค€(SQL-92)์— ๋”ฐ๋ฅด๋Š” ๊ทœ์น™์ด๋ฉฐ, ๋Œ€๋ถ€๋ถ„์˜ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ด€๋ฆฌ ์‹œ์Šคํ…œ(DBMS)์—์„œ๋„ ๋™์ผํ•˜๊ฒŒ ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.๋ฐ˜๋ฉด์— **ํฐ ์ธ์šฉ( ")**์€ ์ผ๋ฐ˜์ ์œผ๋กœ **์‹๋ณ„์ž(์‹๋ณ„์ž)**๋ฅผ ๊ฐ์‹ธ๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ํ…Œ์ด๋ธ” ์ด๋ฆ„์ด๋‚˜ ์—ด์ด SQL ํ‚ค์›Œ๋“œ(์˜ˆ: SELECT, FROM)์™€ ์ถฉ๋Œํ•˜๊ฑฐ๋‚˜ ๊ณต๋ฐฑ์ด ํฌํ•จ๋œ ๊ฒฝ์šฐ ํฐ ์ธ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.๊ตฌ์„ฑ์š”์†Œ:์ž‘์€ ๋ฆฌํ„ฐ( ') : ๋ฌธ์ž์—ด ๋ฆฌํ„ฐ๋Ÿด์— ์‚ฌ์šฉSELECT * FROM employees WHERE name = 'John'; ํฐ ์ธ์šฉ( ") : ์ธ์šฉ(ํ…Œ์ด๋ธ”๋ช…, ์ถ”์ ๋ช…) ๊ฐ์‹ธ๊ธฐSELECT "first name" AS full_name FROM employees;

DB 2024.11.14

[Error][JAVA] Cannot format given Object as a Number

"์ฃผ์–ด์ง„ ๊ฐ์ฒด๋ฅผ ์ˆซ์ž๋กœ ํฌ๋งทํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค" ์˜ค๋ฅ˜๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ Java ์™€ ๊ฐ™์€ ํฌ๋งคํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์œ ํšจํ•˜์ง€ ์•Š๊ฑฐ๋‚˜์ˆซ์ž ๊ฐ’์œผ๋กœ ํ•ด์„ํ•  ์ˆ˜ ์—†๋Š” ๊ฐ’์„ ํฌ๋งทํ•˜๋ ค๊ณ  ํ•  ๋•Œ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.DecimalFormat. ๋ฌธ์ œ๋ฅผ ๋””๋ฒ„๊น…ํ•˜๊ณ  ํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.์ผ๋ฐ˜์ ์ธ ์›์ธ๊ณผ ํ•ด๊ฒฐ์ฑ…1. ์ˆซ์ž๊ฐ€ ์•„๋‹Œ ๊ฐœ์ฒด ์ „๋‹ฌํฌ๋งทํŒ…๋˜๋Š” ๊ฐœ์ฒด๊ฐ€ ์œ ํšจํ•œ์ง€ Number(์˜ˆ: Integer, Double, ๋˜๋Š” BigDecimal) ๋˜๋Š” String์ˆซ์ž๋กœ ๊ตฌ๋ฌธ ๋ถ„์„๋  ์ˆ˜ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”.2. Null ๊ฐ’๊ฐ์ฒด๊ฐ€ ์ด๋ฉด null์„œ์‹์ด ์‹คํŒจํ•ฉ๋‹ˆ๋‹ค.3.๋ถ€์ ์ ˆํ•œ ๋ฌธ์ž์—ด ์ž…๋ ฅ์ž…๋ ฅ์ด String์œ ํšจํ•œ ์ˆซ์ž ํ‘œํ˜„์ด ์•„๋‹Œ ๊ฒฝ์šฐ(์˜ˆ: "abc"), ์„œ์‹์ด ์‹คํŒจํ•ฉ๋‹ˆ๋‹ค.์ˆ˜์ •: ๋จผ์ € ๋ฌธ์ž์—ด์„ ์ˆซ์ž๋กœ ๊ตฌ๋ฌธ ๋ถ„์„ํ•ฉ๋‹ˆ๋‹ค. 4.๋ถ€์ ์ ˆํ•œ ๊ฐœ์ฒด ์œ ํ˜• , , ๋˜๋Š” ์‚ฌ์šฉ์ž ..

Error 2024.11.13

[JAVA] BigDecimal ๊ณฑํ•˜๊ธฐ

import java.math.BigDecimal;import java.text.DecimalFormat;public class Main { public static void main(String[] args) { BigDecimal adTotSupplyAmt = new BigDecimal("1000"); // ์˜ˆ์‹œ ๊ฐ’ BigDecimal result = adTotSupplyAmt.multiply(new BigDecimal("0.1")); // 0.1์„ BigDecimal๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ๊ณฑํ•˜๊ธฐ DecimalFormat df = new DecimalFormat("#,###.##"); // ์›ํ•˜๋Š” ํ˜•์‹์œผ๋กœ ํฌ๋งท String formattedResult = ..

JAVA 2024.11.12
728x90
๋ฐ˜์‘ํ˜•