Monday, February 7, 2011

Obtaining a Java Date object for a Specific Time Zone

I want to get a java.util.Date object that represents a specific time at a specific time zone. Say "23:59 Wednesday 16 Feb 2011 EST"

TimeZone tz = TimeZone.getTimeZone("US/Eastern");
Calendar cal = Calendar.getInstance( tz );
cal.set(Calendar.YEAR, 2011);
cal.set(Calendar.MONTH, Calendar.FEBRUARY);
cal.set(Calendar.DAY_OF_MONTH, 16);
cal.set(Calendar.AM_PM, Calendar.PM);
cal.set(Calendar.HOUR, 11);
cal.set(Calendar.MINUTE, 59);
// cal.getTime() returns the Date for 23:59pm 16 Feb 2011 EST


Friday, February 4, 2011

Add JVM options to Glassfish

I want to add a JVM option to Glassfish, so that when it will always start with the JVM option. Let's just say I want to add the below JVM option:


2 ways to do it:

Glassfish Admin Console
By using the Glassfish Admin Console, we can easily add the required option. Just:

  1. go to http://my.glassfish.url:4848/ (the default port is 4848),
  2. login
  3. on the left select "Application Server"
  4. select the tab "JVM Settings"
  5. select the sub-tab "JVM Options"
  6. add your option there

XML Config
Go to the following Glassfish path on the file system:
and edit the file domain.xml. Within that XML is an element called <java-config>. Within that element, add a child <jvm-options> with the option like so: