Scala如何使用datetime库使用前导0填充月份。不想使用字符串格式
我知道你想要这样的东西:Scala如何使用datetime库使用前导0填充月份。不想使用字符串格式,scala,Scala,我知道你想要这样的东西: val SomePattern = DateTimeFormat.forPattern("yyyy/MM") val folderLocation = s"location/${SomePattern.print(d)}" 是否有一个Scala库可以将0填充到一个月?尝试以下方法: import java.time.LocalDate, java.time.format.DateTimeFormatter DateTimeFormatter.ofPattern(
val SomePattern = DateTimeFormat.forPattern("yyyy/MM")
val folderLocation = s"location/${SomePattern.print(d)}"
是否有一个Scala库可以将0填充到一个月?尝试以下方法:
import java.time.LocalDate, java.time.format.DateTimeFormatter
DateTimeFormatter.ofPattern("yyyy/MM").format(LocalDate.now)
几乎从不使用
LocalDate
,而是将zoneDate
与UTC
一起使用。@SarveshKumarSingh如果用例调用LocalDate
,请使用它。我不同意“几乎从不”的说法,这取决于你在做什么。