728x90
๋ฐ˜์‘ํ˜•

์ „์ฒด ๊ธ€ 1364

[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

[JAVA] ์š”์ผ๊ตฌํ•˜๊ธฐ (ํ•œ๊ธ€)

import java.time.LocalDate;import java.time.format.DateTimeFormatter;import java.time.DayOfWeek;public class DayOfWeekExample { public static void main(String[] args) { String dateStr = "2024-11-14"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // ๋ฌธ์ž์—ด์„ LocalDate๋กœ ๋ณ€ํ™˜ LocalDate date = LocalDate.parse(dateStr, formatter); // ์š”์ผ ๊ตฌํ•˜๊ธฐ ..

JAVA 2024.11.08

[js] switch ๋ฌธ ์•ˆ์—์„œ ๊ฐ™์€ ๋ณ€์ˆ˜๋ช… ์‚ฌ์šฉ

switch ๋ฌธ์—์„œ ๊ฐ case ๋ธ”๋ก์€ ๋™์ผํ•œ ์Šค์ฝ”ํ”„๋ฅผ ๊ณต์œ ํ•˜๋ฏ€๋กœ, ๊ฐ case ๋‚ด์—์„œ ๊ฐ™์€ ๋ณ€์ˆ˜๋ช…์„ ์„ ์–ธํ•˜๋ฉด ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์€ ํฌ๊ฒŒ ๋‘ ๊ฐ€์ง€์ž…๋‹ˆ๋‹ค.๋ณ€์ˆ˜๋ช… ๋ณ€๊ฒฝ: ๊ฐ case ๋ธ”๋ก์—์„œ ๋‹ค๋ฅธ ๋ณ€์ˆ˜๋ช…์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.switch ๋ฌธ ์™ธ๋ถ€์— ๋ณ€์ˆ˜ ์„ ์–ธ: ๋ณ€์ˆ˜๋ฅผ switch ๋ฌธ ๋ฐ–์—์„œ ์„ ์–ธํ•˜๊ณ , ๊ฐ case ๋ธ”๋ก์—์„œ ๊ฐ’์„ ํ• ๋‹นํ•ฉ๋‹ˆ๋‹ค.let value = 2;let number; // switch๋ฌธ ์™ธ๋ถ€์—์„œ ๋ณ€์ˆ˜ ์„ ์–ธswitch (value) { case 1: number = 10; break; case 2: number = 20; break; default: number = 0; break;}console.log(number); // 20  let์ด๋‚˜ const ..

Front/JS & jQuery 2024.11.07

[js] Quill Editor ๋†’์ด ์„ค์ •

Quill ์—๋””ํ„ฐ์˜ ๋†’์ด๋ฅผ ํ…์ŠคํŠธ ๊ธธ์ด์— ๋งž๊ฒŒ ์ž๋™์œผ๋กœ ์กฐ์ •ํ•˜๋ ค๋ฉด, ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 1. CSS๋กœ ์ž๋™ ๋†’์ด ์กฐ์ •: overflow-y: hidden; ์†์„ฑ์„ ์‚ฌ์šฉํ•˜๊ณ  height๋ฅผ ์ž๋™์œผ๋กœ ์กฐ์ •ํ•˜๋„๋ก ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Quill ์—๋””ํ„ฐ์˜ ๊ธฐ๋ณธ div๋ฅผ ๋Œ€์ƒ์œผ๋กœ ํ•˜์—ฌ, ์—๋””ํ„ฐ ๋†’์ด๋ฅผ ํ…์ŠคํŠธ ๊ธธ์ด์— ๋งž๊ฒŒ ํ™•์žฅํ•˜๋„๋ก ๋งŒ๋“ญ๋‹ˆ๋‹ค..ql-editor { overflow-y: hidden; /* ์Šคํฌ๋กค๋ฐ” ์ˆจ๊ธฐ๊ธฐ */ min-height: 150px; /* ์ตœ์†Œ ๋†’์ด ์„ค์ • */} 2. JavaScript๋กœ ๋™์ ์œผ๋กœ ๋†’์ด ์กฐ์ •: ํ…์ŠคํŠธ์˜ ๊ธธ์ด์— ๋”ฐ๋ผ ์—๋””ํ„ฐ์˜ height๋ฅผ ๋™์ ์œผ๋กœ ์กฐ์ •ํ•˜๋ ค๋ฉด, text-change ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ๋†’์ด๋ฅผ ์žฌ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.const q..

Front/JS & jQuery 2024.11.06

[JAVA] LocalDate ์ฐจ์ด ๊ตฌํ•˜๊ธฐ

LocalDate๋‘ ๊ฐ์ฒด ์‚ฌ์ด์˜ ์ •ํ™•ํ•œ ๋‚ ์งœ ์ฐจ์ด๋ฅผ ์–ป์œผ๋ ค๋ฉดChronoUnit.DAYS.between, import java.time.LocalDate;import java.time.format.DateTimeFormatter;import java.time.temporal.ChronoUnit;// ํ–‰์‚ฌ๊ธฐ๊ฐ„ ๊ณ„์‚ฐString usagSdt = crInfo.getUsagSdt();String usagEdt = crInfo.getUsagEdt();// ๋ฌธ์ž์—ด์„ LocalDate๋กœ ๋ณ€ํ™˜DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");LocalDate startDate = LocalDate.parse(usagSdt, formatter);L..

JAVA 2024.11.05

[JAVA] Period ๋กœ +1์ผ ๋”ํ•˜๊ธฐ

Period์—ฌ์ „ํžˆ ์ฐจ์ด๋ฅผ ๊ณ„์‚ฐํ•˜๋Š” ๋ฐ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์ง€๋งŒ ,Period'์˜ ๋ฐฉ๋ฒ•์€ ํ•ด๋‹น ์›” ๋‚ด์˜getDays() ์ผ์ˆ˜ ์ฐจ์ด๋งŒ ์ œ๊ณตํ•˜๋ฉฐ ,๋‚ ์งœ๊ฐ€ ์—ฌ๋Ÿฌ ๋‹ฌ ๋˜๋Š” ์—ฌ๋Ÿฌ ํ•ด์— ๊ฑธ์ณ ์žˆ๋Š” ๊ฒฝ์šฐ ์˜คํ•ด์˜ ์†Œ์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.๊ณ„์† ์‚ฌ์šฉํ•˜๋ ค๋ฉด  ์ผ์ˆ˜ ๊ธฐ์ค€์œผ๋กœ ์ „์ฒด ์ฐจ์ด๋ฅผ ๊ณ„์‚ฐํ•˜๊ณ  ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ชจ๋“  ๊ฒƒ์„ ์ผ์ˆ˜๋กœ ๋ณ€ํ™˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.// ํ–‰์‚ฌ๊ธฐ๊ฐ„ ๊ณ„์‚ฐString usagSdt = crInfo.getUsagSdt();String usagEdt = crInfo.getUsagEdt();// ๋ฌธ์ž์—ด์„ LocalDate๋กœ ๋ณ€ํ™˜DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");LocalDate startDate = LocalDate.parse(usagSdt, forma..

JAVA 2024.11.04

[Mybatis] ์ˆซ์ž ์ปฌ๋Ÿผ์ธ๋ฐ ๊ฐ’์ด 0์ผ๋•Œ ์ปฌ๋Ÿผ๊ฐ’ != null and ์ปฌ๋Ÿผ๊ฐ’ !='' ์„ ํ†ต๊ณผํ•˜์ง€ ๋ชปํ•ด์„œ ๊ฐ’์ด ์—†๋Š” ๊ฒƒ์œผ๋กœ ์ฒ˜๋ฆฌ๋ ๋•Œ

์„ ์‚ฌ์šฉํ•ด์„œ ์•ˆ์— ์ปฌ๋Ÿผ ๊ฐ’์ด ์ „๋ถ€  ์ฒ˜๋ฆฌํ•ด์„œ ๊ฐ’์ด null ์ด๋‚˜ ๋นˆ๋ฌธ์ž์—ด์ด ์•„๋‹ˆ๋ฉด update ํ•˜๋ ค๊ณ  ์ž‘์„ฑ์„ ํ•˜์˜€๋Š”๋ฐ,๊ฐ’์ด ์ „๋ถ€ 0 ์ด๋‹ˆ๊นŒ ์•„๋ฌด ๊ฐ’๋„ ์—†๋Š” ๊ฒƒ์œผ๋กœ ๋‚˜์™€์„œ update ๋ฌธ์— SET ์ด ๋น ์ง„ ๊ฒƒ์œผ๋กœ ๊ฐ„์ฃผ๋˜์–ด ์—๋Ÿฌ๊ฐ€ ๋‚ฌ๋‹ค.์–ด์ฐจํ”ผ null ์ด๋ฉด 0์œผ๋กœ ์ž…๋ ฅํ•œ๋‹ค๋Š”  COALESCE(TO_NUMBER(NULL),0) ์œผ๋กœ ์ž‘์„ฑํ•ด ๋‘ฌ์„œ if๋ฌธ์„ ๋‹ค ๋บ๋‹ค. MyBatis์—์„œ `` ๋ฌธ์—์„œ ๊ฐ’์„ ํ‰๊ฐ€ํ•  ๋•Œ `null`, `""` (๋นˆ ๋ฌธ์ž์—ด), ๋•Œ๋กœ๋Š” `0`๊ณผ ๊ฐ™์€ ํŠน์ • ๊ฐ’์ด "falsy"๋กœ ๋™์ž‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฆ‰, ํŠนํžˆ ํ‘œํ˜„์‹์ด ๋ถ€์šธ ๊ฒ€์‚ฌ์™€ ์œ ์‚ฌํ•œ ๊ฒฝ์šฐ ์กฐ๊ฑด ๊ฒ€์‚ฌ๋ฅผ ํ†ต๊ณผํ•˜์ง€ ๋ชปํ•ฉ๋‹ˆ๋‹ค. ### MyBatis์—์„œ Falsy ๊ฐ’๊ณผ `0`์— ๋Œ€ํ•œ ์„ค๋ช… **JavaScript**์™€ ๊ฐ™์€ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์—์„œ `n..

DB 2024.11.03
728x90
๋ฐ˜์‘ํ˜•