为什么我在模型的属性中设置Calendar.getInstance()时会出现NullPointerException?

时间:2016-08-11 12:56:23

标签: java hibernate jpa calendar datetime-format

在我的模特中我有这个:

@Entity
public class Plan {
  ...
  @Temporal(TemporalType.TIMESTAMP)
  @Column(nullable = false)
  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  private Calendar creationDate;
  ...

在eclipse调试器中,我在这行中有一个NullPointerException:

plan.setCreationDate(instance);

1 个答案:

答案 0 :(得分:1)

可能您的android:configChanges="orientation|keyboardHidden|screenSize"对象未被实例化

这样可以防止异常:

plan