如何删除 ZoneId?
How to remove ZoneId?
感谢您一直以来的帮助。
我的项目有问题。
我要删除Zoned Id只留时间
如何删除分区 ID?
它是在Spring Boot Framework中使用kotlin编写的。
data class AvailableScheduleRequest (
val address: String,
val date: LocalDate,
val people: Long,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "Asia/Seoul")
val hour: ZonedDateTime
)
@RestController
class Controller(
val newBookingElasticSearchService: NewBookingElasticSearchService
) {
@RequestMapping("/")
@ResponseBody
fun get(@RequestBody param: Map<String, Any>): List<AvailableRestaurant> {
val json = JacksonUtils.om.writeValueAsString(param)
val availableScheduleRequest =
JacksonUtils.om.readValue(json, AvailableScheduleRequest::class.java)
println(availableScheduleRequest.hour)
}
}
object JacksonUtils {
val om = ObjectMapper()
init {
val module = SimpleModule()
module.addDeserializer(String::class.java, JsonRawValueDeserializer.INSTANCE)
om.registerModule(JavaTimeModule())
om.registerModule(KotlinModule())
om.registerModule(module)
om.dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX")
om.setTimeZone(TimeZone.getDefault())
om.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
om.configure(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true)
om.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true)
om.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true)
}
此代码输出:
2019-10-02T07:00+09:00[Asia/Seoul]
但我想得到这个:
2019-10-02T07:00+09:00
如何获得?
感谢大家一直以来的努力!!
而不是ZonedDateTime
, you could use OffsetDateTime
。
感谢您一直以来的帮助。
我的项目有问题。
我要删除Zoned Id只留时间
如何删除分区 ID?
它是在Spring Boot Framework中使用kotlin编写的。
data class AvailableScheduleRequest (
val address: String,
val date: LocalDate,
val people: Long,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "Asia/Seoul")
val hour: ZonedDateTime
)
@RestController
class Controller(
val newBookingElasticSearchService: NewBookingElasticSearchService
) {
@RequestMapping("/")
@ResponseBody
fun get(@RequestBody param: Map<String, Any>): List<AvailableRestaurant> {
val json = JacksonUtils.om.writeValueAsString(param)
val availableScheduleRequest =
JacksonUtils.om.readValue(json, AvailableScheduleRequest::class.java)
println(availableScheduleRequest.hour)
}
}
object JacksonUtils {
val om = ObjectMapper()
init {
val module = SimpleModule()
module.addDeserializer(String::class.java, JsonRawValueDeserializer.INSTANCE)
om.registerModule(JavaTimeModule())
om.registerModule(KotlinModule())
om.registerModule(module)
om.dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX")
om.setTimeZone(TimeZone.getDefault())
om.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
om.configure(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true)
om.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true)
om.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true)
}
此代码输出:
2019-10-02T07:00+09:00[Asia/Seoul]
但我想得到这个:
2019-10-02T07:00+09:00
如何获得?
感谢大家一直以来的努力!!
而不是ZonedDateTime
, you could use OffsetDateTime
。