我尝试使用角形formatDate
result = {JsonSyntaxException@7237} Method threw 'com.google.gson.JsonSyntaxException' exception.
cause = {MalformedJsonException@7241} "com.google.gson.stream.MalformedJsonException: Invalid escape sequence at line 1 column 65 path $[0].codeRule"
detailMessage = "com.google.gson.stream.MalformedJsonException: Invalid escape sequence at line 1 column 65 path $[0].codeRule"
stackState = null
stackTrace = {StackTraceElement[28]@7243}
suppressedExceptions = {Collections$EmptyList@7244} size = 0
shadow$_klass_ = {Class@1694} "class com.google.gson.JsonSyntaxException"
shadow$_monitor_ = -2082115852
所以我使用此代码
"2019-01-01T00:00:00Z"
结果为formatDate(
'2019-01-01',
'yyyy-MM-ddT00:00:00Z',
'en-US'
)
Z被区域替换。有一种有效的方法可以制作我需要的格式吗?
答案 0 :(得分:2)
您必须将Z
作为字符串转义,否则将按照this对待
"yyyy-MM-ddT00:00:00\'Z\'"
formatDate(
'2019-01-01',
"yyyy-MM-ddT00:00:00\'Z\'",
'en-US'
)