scala-java-locales icon indicating copy to clipboard operation
scala-java-locales copied to clipboard

SimpleDateFormat.format - NotImplementedError - escaping text fragment with single quotes

Open Sciss opened this issue 5 years ago • 2 comments

import java.util.Locale
val fmt = new java.text.SimpleDateFormat("[d MMM yyyy, HH:mm''ss.SSS] 'AudioFile' ", Locale.US)
fmt.format(new java.util.Date)

This throws NotImplementedError (???). Goes away when I remove the escaped fragment 'AudioFile'.

  • https://scastie.scala-lang.org/0fjO9iLSSieLHc4we399cg
  • https://scastie.scala-lang.org/dbmlsCXgQTOthZ13UtJJJQ (JVM - working)

The JDK docs are clear:

Text can be quoted using single quotes (') to avoid interpretation.

Sciss avatar Oct 31 '20 01:10 Sciss

Also this rule is not followed:

"''" represents a single quote

instead they are presented as two single quotes.

Sciss avatar Oct 31 '20 01:10 Sciss

Hi, this implementation of SimpleDateFormat is not really for production use, it is only a minimal set of stubs to make DateTimeFormatter work on scala-java-time. I'd discourage its direct use

Improvements are welcome of course if you want to fix its shortcomings

cquiroz avatar Oct 31 '20 02:10 cquiroz