Skip to content

[Item 12] toString() vs. localization #16

@mikaelstaldal

Description

@mikaelstaldal

I think there is one point about toString() which could be worth being mentioned in Item 12.

  • You should not misuse toString() for displaying objects in a user interface, since that will preclude localization. Rather use java.text.MessageFormat or something similar for that purpose.

This is also highlighted in the text which says that phone numbers have a standard string representation. This "standard" is actually only valid in US, Canada and the other countries with country code 1. Elsewhere in the world, phone numbers looks different.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions