Thiago B A Salles Thiago B A Salles - 1 year ago 43
Java Question

Why i have a NullPointerException when i set Calendar.getInstance() in a attribute of model?

In my model i have this:

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

In eclipse debugger, i have a NullPointerException in this line:


Answer Source

Probably your plan object isn't instantiated...

This will prevent the exception:

if (plan != null){