Ich habe ein DateTime-Objekt, und ich möchte es mit einem bestimmten Format drucken, sagen wir yyyy-MM-dd
.Scala: Drucken eines DateTime-Objekts in einem bestimmten Format
Ich habe
versuchtval date = DateTime.now()
val format = "yyyy-MM-dd"
println(date.formatted(format))
bekam aber yyyy-MM-dd
als ob das Format nicht erkannt wurde.
Ich habe auch versucht
val formatter = new SimpleDateFormat(format)
println(
bekam aber
Objekt kann nicht als Datum java.lang.IllegalArgumentException bestimmten Format: Kann nicht gegeben Objekt als ein Datumsformat
Wie drucke ich das DateTime-Objekt in dem Format meiner Wahl?
ist es ein joda Datetime? – pedrorijo91
Wenn ja, schauen Sie: http://StackOverflow.com/Questions/20331163/How-to-Format-Joda-TimeTimeTime-To-only-mm-dd-yyyy – pedrorijo91
Mögliche Duplikat von [Wie Joda zu formatieren -Time DateTime auf nur mm/tt/jjjj?] (Http://stackoverflow.com/questions/20331163/how-to-format-joda-time-datetime-to-only-mm-dd-yyyy) – pedrorijo91