I am trying to update the class test in JAVA . Here when I am trying to update it as shown below It always adds 4 hours to the created Date. I am doing something like this. I am using LocalDateTime for createdDate. I think 4 hours is because of the Zone.
Any help is appreciated. Please let me know.
Thanks in Advance. :)
public Test updateTest(TestDTO testDTO, Employee employee) throws
TransactionSystemException {
Test test = TestRepository.findOne(testDTO.getId());
Test returnTest = null;
testDTO = (TestDTO) CustomData.convertData(testDTO);
test.setTestDate(testDTO.getTestDate());
if(testDTO.getCreatedDate() != null){
test.setCreatedDate(test.getCreatedDate());
}
test.setCreatedBy(test.getCreatedBy());
test.setTestProcedureId(testDTO.getTestProcedureId());
test.setCollectionSiteType(testDTO.getCollectionSiteType());
test.setMobileId(testDTO.getMobileId());
returnTest = TestRepository.save(test);
return returnTest;
}
// Test Domain
@Entity
@Table(name = "test")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Test implements Serializable {
@Id
@NotNull
@Size(max = 30)
@Column(name = "id", length=30)
private String id;
@Column(name = "created_date")
private LocalDateTime createdDate;
@Column(name="created_by")
private Long createdBy;
@Column(name="test_procedure_id", nullable = false)
private Long testProcedureId;
@Column(name="collection_site_type", nullable = false)
private String collectionSiteType;
@Column(name="mobile_id")
private Long mobileId;
@Column(name = "updated_date")
private LocalDateTime updatedDate;
// --------------------- GETTER / SETTER METHODS ---------------------
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Long getTestProcedureId() {
return testProcedureId;
}
public LocalDateTime getCreatedDate() {
return createdDate;
}
public void setCreatedDate(LocalDateTime createdDate) {
this.createdDate = createdDate;
}
public Long getCreatedBy() {
return createdBy;
}
public void setCreatedBy(Long createdBy) {
this.createdBy = createdBy;
}
public void setTestProcedureId(Long testProcedureId) {
this.testProcedureId = testProcedureId;
}
public String getCollectionSiteType() {
return collectionSiteType;
}
public void setCollectionSiteType(String collectionSiteType) {
this.collectionSiteType = collectionSiteType;
}
public Long getMobileId() {
return mobileId;
}
public void setMobileId(Long mobileId) {
this.mobileId = mobileId;
}
public LocalDateTime getUpdatedDate() {
return updatedDate;
}
public void setUpdatedDate(LocalDateTime updatedDate) {
this.updatedDate = updatedDate;
}
}