How can I read the SQL Server Timestamp with Time zone in java

I came across a weird issue, during the cloud migration where the MS SQL Server  on cloud made use of time zone UTC. Some where in the code, I had a check where the update time stamp which is based on CDT is compared against the DB server time.

This is how I mitigated that issue,

private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat
.forPattern("yyyy-MM-dd HH:mm:ss.SSSSSSS Z");


resultSetData = dbConfig.executeQuery("SELECT SYSDATETIMEOFFSET() AS CurrentDateTime");

For some reason, the time returned by the above query has 7 precision for milli seconds.

if (resultSetData != null && resultSetData .next()) {
String currentDateTimeStr = resultSetData .getString("CurrentDateTime");
DateTime datetime = DATE_TIME_FORMATTER.parseDateTime(currentDateTimeStr);
currentDBTimestamp = datetime.getMillis();
}

Error : RuntimeException: No JPA EntityManagerFactory configured for name [default] in Play Framework 2.0

I got this error : [RuntimeException: No JPA EntityManagerFactory configured for name [default]] when i try to create a controller method with @Transactional.

Solution:
In application.conf file, put the following entry and assign it to the default  entry in Persistance.xml

jpa.default=Default non-jts-data-source entry from Persistance.xml

 Python Basics How to check the version of Python interpreter mac terminal

Popular in last 30 days