์ƒˆ์†Œ์‹

๐Ÿ“ŒDevelop/Javascript ์ฃผ์„ฌ์ฃผ์„ฌ

Java LocalDateTime ๋ฅผ Javascript ์—์„œ ์ฒ˜๋ฆฌ ํ•  ๋•Œ

  • -

 

 

๋‚ด์šฉ

RDBMS์—์„œ Model ๋˜๋Š” Dto ์— Date ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„์˜ค๋‹ค๋ณด๋ฉด ๋ฐ€๋ฆฌ์„ธ์ปจ์ฆˆ๊นŒ์ง€ ํฌํ•จ๋˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋‹ค. (timestamp)

์ตœ๋Œ€ํ•œ ์ž‘์—… ๋‹จ์œ„๋ฅผ ์ตœ์†Œํ™” ํ•  ๋ฐฉ๋ฒ•์ด ๋ฌด์—‡์ด ์žˆ์„๊นŒ ๊ณ ๋ฏผํ•˜๋‹ค๊ฐ€ Javascript ์—์„œ API๋กœ ๋ถˆ๋Ÿฌ์˜ฌ ๋•Œ, ์ œ์ผ ๋‹จ์ˆœํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ convert ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ฑ„ํƒํ–ˆ๋‹ค.

 

์ฝ”๋“œ

function convertDateFormat(date) {
  let dateSplit = date;
  if (date.indexOf("T") != -1) {
    dateSplit = date.split("T");
    dateSplit = dateSplit[0] + ' ' + dateSplit[1].substring(0, 8);
  }
  return dateSplit;
}
๋ฐ˜์‘ํ˜•
Contents

ํฌ์ŠคํŒ… ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค

์ด ๊ธ€์ด ๋„์›€์ด ๋˜์—ˆ๋‹ค๋ฉด ๊ณต๊ฐ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.