Monday, September 9, 2013

SQL Server tips to convert UTC Long value to Human Readable date

To Convert millisecond UTC time value in log to SQL SERVER Date Time with millisecond:
DECLARE @UTC BIGINT
SET @UTC = 1348203320997 
SELECT DATEADD(MILLISECOND, @UTC % 1000, DATEADD(SECOND, @UTC / 1000, '19700101')) 
To extract month, year values from a date-time value in SQL SERVER:
select 
datepart(month,getdate()) -- integer (1,2,3...)
,datepart(year,getdate()) -- integer
,datename(month,getdate()) -- string ('September',...) 
In MySQL:
select MONTHNAME(FROM_UNIXTIME(1375437322612/1000))select MONTH(FROM_UNIXTIME(1375437322612/1000))select YEAR(FROM_UNIXTIME(1375437322612/1000))

Using OQL in Eclipse MAT for finding instances of Finalizer class

This query returns all objects which are held by the Finalizer object.

SELECT OBJECTS referent FROM INSTANCEOF java.lang.ref.Finalizer

The keyword OBJECTS tells the compiler to treat the result as an object list (which makes it easier to work with this). The INSTANCEOF looks for objects of this class and its sub-classes.

Once you have the list (this is true for any list of objects), press the right most button in the tool bar "Show as Histogram". This groups the objects by class or by class loader. And this is what you want.


Alternatively, you can choose "Java Basics" -> "References" -> "Finalizer Reference Statistics" from the Query menu (the drop-down menu with the blue circles in the toolbar). This opens 2 windows: the first table contains the result of the query above.

The second table says which of those objects in the "referent" field would be garbage collected if the reference via "referent" (and only this reference) would be removed. Alas the retained set if the Finalizers were gone (which is different, remember, because the same object could be referenced from other corners of the object graph).