Java
How to convert local timestamp to UTC in Java?
The below code can be used to convert the local timestamp to UTC in Java. Converting to any other timezone is very easy by changing the below UTC into the target timezone. public static String getCurrentUTCTimestamp() { SimpleDateFormat dateFormatter = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss z”); final TimeZone utc = TimeZone.getTimeZone(“UTC”); dateFormatter.setTimeZone(utc); return dateFormatter.format(new java.util.Date()); }
org .apache .xerces .dom Deferred Document Impl getXmlStandalone Exception
java.lang.AbstractMethodError: org.apache.xerces.dom.DeferredDocumentImpl.getXmlStandalone()Z Resolution: This error occurs when there is NO xercesImpl.jar in the class path. Remove the xerces.jar from the classpath and add xercesimpl.jar in the classpath. Good luck!
Java Exceptions Hierarchy
In Java, exceptions are objects, when you throw an exception, you are throwing an object. You can’t throw just any object as an exception as Exceptions needs to be in the inheritance hierarchy of Throwable. Throwable is the base class for the Exceptions. The Hierarchy is like below. Throwable is the base class. Error and [...]
Cursor Is Closed Exception In Java – Fixed (Resolved)
In java, when there is a stored procedure call which returns the Cursor as a ResultSet, there is a possibility that, Cursor is closed exception might occur. Here is the stack trace which shows that. java.sql.SQLException: Cursor is closed. at oracle.jdbc.driver.T4CResultSetAccessor.getCursor(T4CResultSetAccessor.java:323) at oracle.jdbc.driver.ResultSetAccessor.getObject(ResultSetAccessor.java:85) at oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:1401) at com.ibm.ws.rsadapter.jdbc.WSJdbcCallableStatement.getObject(WSJdbcCallableStatement.java:443) Solution to over come the “Cursor is closed” [...]
