Coder Social home page Coder Social logo

Comments (3)

TreeJin99 avatar TreeJin99 commented on June 15, 2024 2

안녕하세요~ 유닛2 캠핑지기 남우진입니다. 위 hhyeok1026님께서 써주신 부분이 정답이 맞습니다!

return NumberFormat.getCurrencyInstance().format(tip)로 되어있던 부분 중
getCurrencyInstance()에 들어갈 인자 값의 Default는 시스템의 locale로 맞춰있기 때문입니다.
예시: NumberFormat.getCurrencyInstance(Locale.getDefault()).format(price)

이에 따라 다음 같이 getCurrencyInstance의 인자 값으로 'Locale.US'를 추가해주시면 해당 문제는 깔끔히 해결이 됩니다!
return NumberFormat.getCurrencyInstance(Locale.US).format(tip)

추가적으로 Locale은 아래 스크린샷을 보시면 알 수 있듯이 JVM 인스턴스에 대한 Default Locale의 현재 값을 가져온다고 하네요! ㅎㅎ

스크린샷 2022-11-17 오후 10 39 51

from composecamp2022-for-beginners.

hhyeok1026 avatar hhyeok1026 commented on June 15, 2024 1

NumberFormat.getCurrencyInstance() 메서드가
휴대폰내의 setting - 언어에 대해서 통화가 표시 되는 것 같아요

아마도 앱 내에서 통화를 달러로 고정 시키려면, 파라미터 locale이 있는 메서드를 쓰면 될 듯하네요
https://developer.android.com/reference/java/text/NumberFormat#getCurrencyInstance(java.util.Locale)

  • Q)
    여기서 저도 추가적으로 궁금한게,
    유닛 테스트 할 때도 원화로 표시가 되던데, 유닛 테스트에서는 어떻게 Default locale값을 가져오는지가 궁금하네요.
    윈도우 세팅값을 자바에서 읽어오는 걸까요..?

from composecamp2022-for-beginners.

ZungTa avatar ZungTa commented on June 15, 2024 1

감사합니다. 궁금증이 해결됐네요.

from composecamp2022-for-beginners.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.