I have the following code now. This is basically called to get all the summary (in this case summary about some tests). Timezone is set to UTC currently. I want to get all data based on the local time zone. Please provide me any idea to do this?
public List<TestEntity> getAllTestSummary(String status) {
Timestamp timestampEnd = new Timestamp(System.currentTimeMillis());
long tenAgo = System.currentTimeMillis() - TEN_MINUTES;
Timestamp timestampStart = new Timestamp(tenAgo);
String TSPATTERN = "yyyy-MM-dd HH:mm:ss";
DateFormat df = DateFormat.getDateTimeInstance();
df = new SimpleDateFormat(TSPATTERN);
df.setTimeZone(TimeZone.getTimeZone("UTC"));
timestampStart = Timestamp.valueOf(df.format(timestampStart).toString());
timestampEnd = Timestamp.valueOf(df.format(timestampEnd).toString());
return testRepository.findByStatusIgnoreCase(status);
}
I tried using joda
but didn't get the desired output.