@Column(name = "BEGINTIME")
@Temporal(TemporalType.TIMESTAMP)
@JsonFormat(shape = JsonFormat.Shape.STRING, timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date beginTime; // java.util.Date
@Test
public void test() throws IOException {
ObjectMapper mapper = new ObjectMapper();
JsonContext jsonContext = Ebean.json();
mapper.registerModule(new JacksonEbeanModule(jsonContext));
String jsonWithUnknown = "{\"id\":42,\"unknownProp\":\"foo\",\"name\":\"rob\",\"version\":1, \"beginTime\":\"2018-02-01 11:11:22\"}";
Customer customer3 = jsonContext.toBean(Customer.class, jsonWithUnknown);
// DateTime
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateStr = sdf.format(customer3.getBeginTime());
assertEquals(dateStr, "2018-02-01 11:11:22");
}
java.lang.RuntimeException: Error parsing Datetime[2018-02-01 11:11:22]
at io.ebeaninternal.server.type.DateTimeJsonParser.parse(DateTimeJsonParser.java:50)
at io.ebeaninternal.server.type.ScalarTypeBaseDateTime.jsonRead(ScalarTypeBaseDateTime.java:108)
at io.ebeaninternal.server.deploy.BeanProperty.jsonRead(BeanProperty.java:1439)
at io.ebeaninternal.server.deploy.BeanDescriptorJsonHelp.jsonReadProperties(BeanDescriptorJsonHelp.java:142)
at io.ebeaninternal.server.deploy.BeanDescriptorJsonHelp.jsonReadObject(BeanDescriptorJsonHelp.java:122)
at io.ebeaninternal.server.deploy.BeanDescriptorJsonHelp.jsonRead(BeanDescriptorJsonHelp.java:91)
at io.ebeaninternal.server.deploy.BeanDescriptor.jsonRead(BeanDescriptor.java:3166)
at io.ebeaninternal.server.text.json.DJsonContext.toBean(DJsonContext.java:124)
at io.ebeaninternal.server.text.json.DJsonContext.toBean(DJsonContext.java:115)
at io.ebeaninternal.server.text.json.DJsonContext.toBean(DJsonContext.java:105)
at io.ebeaninternal.server.text.json.DJsonContext.toBean(DJsonContext.java:95)
at io.ebean.jackson.DateTimeTest.test(DateTimeTest.java:29)
Caused by: java.text.ParseException: Unparseable date: "2018-02-01 11:11:22"
at java.text.DateFormat.parse(DateFormat.java:366)
at io.ebeaninternal.server.type.DateTimeJsonParser.parse(DateTimeJsonParser.java:47)
... 45 more
@JsonFormat(shape = JsonFormat.Shape.STRING, timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date beginTime;
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JacksonEbeanModule(jsonContext));
Customer customer3 = jsonContext.toBean(Customer.class, jsonWithUnknown);
@Column(name = "BEGINTIME")
@Temporal(TemporalType.TIMESTAMP)
@JsonFormat(shape = JsonFormat.Shape.STRING, timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date beginTime;
--
---
You received this message because you are subscribed to the Google Groups "Ebean ORM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ebean+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
com.fasterxml.jackson.databind.JsonMappingException: io.ebean.bean.EntityBeanIntercept.preSetter(ZILjava/lang/Object;Ljava/lang/Object;)Ljava/beans/PropertyChangeEvent; (through reference chain: org.example.domain.Customer["id"]) at com.fasterxml.jackson.databind.deser.SettableBeanProperty._throwAsIOE(SettableBeanProperty.java:564) at com.fasterxml.jackson.databind.deser.SettableBeanProperty._throwAsIOE(SettableBeanProperty.java:548) at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:99) at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:258) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:125) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3736) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2726) at io.ebean.jackson.DateTimeTest.test(DateTimeTest.java:28)Caused by: java.lang.NoSuchMethodError: io.ebean.bean.EntityBeanIntercept.preSetter(ZILjava/lang/Object;Ljava/lang/Object;)Ljava/beans/PropertyChangeEvent; at org.example.domain.Customer._ebean_set_id(Customer.java:1) at org.example.domain.Customer.setId(Customer.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:97) ... 39 more
<tile>io.ebean.tile:enhancement:5.1</tile>
To unsubscribe from this group and stop receiving emails from it, send an email to ebean+un...@googlegroups.com.