Category Archives: Java

Generate Thread Dump

jstack PID > outfile

jstack which comes as part JDK would be used to generate thread dump for java application/process. We can find this utility under <JDK_HOME>/bin directory.


jstack <java process id> > <output file>


jstack 12345 > threaddump.txt


Getting timezone and timezone offset

String timezone = Calendar.getInstance().getTimeZone().getDisplayName(false, TimeZone.SHORT);

int timezoneOffset = 0;
Calendar myCalendar = new GregorianCalendar();
int gmtOffset = myCalendar.get(Calendar.ZONE_OFFSET);
int dstOffset = myCalendar.get(Calendar.DST_OFFSET);

timezoneOffset = gmtOffset + dstOffset;