A SimpleDateFormat is created without a locale, so the output changes with the device
What it finds
SimpleDateFormat("yyyy-MM-dd") formats with the default locale, which may use other digits or calendars, so text meant for machines, file names or protocols differs between devices. Passing Locale.ROOT, or the user's locale for text meant for people, says which is meant.
From the rule's source, date_format_locale.rs.
import java.text.SimpleDateFormatimport java.util.Locale val machine = SimpleDateFormat("yyyy-MM-dd")tx0 reports: the date format uses the default localeval fixed = SimpleDateFormat("yyyy-MM-dd", Locale.ROOT) Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/kotlin:date-format-without-locale" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/kotlin:date-format-without-locale] reason="..."tx0 explain tx0/kotlin:date-format-without-locale shows the same in the terminal. Found a false positive? Report it.