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.

Usage:

jstack <java process id> > <output file>

Example:

jstack 12345 > threaddump.txt

Advertisements

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;