使用simpledateformat更改年份

时间:2019-01-09 10:04:12

标签: java date simpledateformat

我通过jpa获得有关实体的信息。 日期31/12/2018 dd / MM / YYYY变为31/12/2019。 在simpledateformat选项上我一定是错的。

LOG.info("date de création :" +entite.getCreatedt ());
SimpleDateFormat sdf =new SimpleDateFormat ( "dd/MM/YYYY" );
LOG.info("date de création formatée :" + sdf.format(entite.getCreatedt ()));

我实体的createdt字段定义如上:

@Column(name = "CREATEDT")
@Temporal(TemporalType.DATE)
private Date createdt;

我得到结果: 信息:创建日期:2018年12月31日星期一00:00:00 信息:日期格式:2019/12/31

您能解释一下为什么2018年变成2019年吗 我尝试过

sdf = new SimpleDateFormat ( "dd/MM/YYYY", new Locale("fr", "FR") );

但结果相同

谢谢

0 个答案:

没有答案
相关问题