JavaOne 2013: Introducing the Java Time API in JDK 8

Posted in Uncategorized on September 23, 2013 by Joey

I really enjoyed attending the Java Time API in JDK 8 class at JavaOne 2013. It was taught by Stephen Colebourne and Roger Riggs, who are the Specification Leads for JSR 310: Date and Time API.

The class centered on the fact that JDK 8 (available 03/18/14) will have a new date and time API. This API will be built from scratch and is based on ideas from the Joda-Time library.

The API will have many classes. Some of the notable ones are:

LocalDate – A date without the time, offset, or timezone
LocalDate date =;
LocalDate date2 = LocaleDate.of(2013,Month.SEPTEMBER,12)
Note that Month is an enum containing each month. Also note that using month integers in the API counts from 1 to 12
LocalDates can also by modified using Adjusters
date.with(lastDayOfMonth()) or date.with(next(TUESDAY))
A LocalDate can be manipulated in various way, such as date.plusMonths(3)

LocalTime – The time of day, without the date, offset, or timezone
LocalTime time =;
A LocalTime can be manipulated in various ways, such as time.plusHours(4) or time.minusMinutes(1)
LocalDateTime – The date and time, without the offset or timezone
LocalDateTime ldt =;
LocalDateTime ldt2 = LocalDateTime.of(2013,Month.SEPTEMBER,12,13,30);

OffsetDate – A date with its offset, without timezone
OffsetTime – Time of day with its offset, without timezone


Java Constructor Rules

Posted in Java on May 21, 2010 by Joey

The following rules must be adhered to when creating Java constructors:

1) The name of the constructor must be the same as the class name for which the constructor is being defined.
2) The constructor must not define a return type.
3) If a constructor is not defined for a class, the compiler creates a default constructor. This default constructor contains no arguments.
4) If a constructor is defined for class, the compiler does not create a default constructor.
5) Overloaded constructors may be created but there cannot be two constructors in the same class with the same argument list.

Add Additional Parameters to an ExtJS Tree Node Click

Posted in ExtJS, JavaScript on May 20, 2010 by Joey

I recently encountered a situation in which I needed to send additional, dynamic parameters to a URL when an ExtJS tree node was clicked. After some trial and error, I discovered that I needed to add a TreeLoader object to my tree. (I was previously trying to use the dataUrl property of the tree itself.)

I had some parameters that were the same for each node. These I defined in the TreeLoader’s baseParams config.

The dynamic parameters I had to handle differently, since I wouldn’t know what they were until the tree node was actually clicked. To capture this click event, I defined the “beforenodeclick” event of the TreeLoader. Then, within this event, I retrieved individual attributes that had been defined for the node (in my case via a JSON packet) and added these to the TreeLoader’s baseParam config.


What is a Java Constructor?

Posted in Java on May 18, 2010 by Joey

In Java, a constructor defines the code that is run when a new object is created.

To create a constructor, define a block of code with the same name as the class. For example, the following defines the construtor for a class called “Painting”.

To invoke a constructor, use the “new” keyword, followed by the name of the class.

When creating a Java constructor, remember the Java Constructor Rules.

How to Get the Web Application Root in a JSP

Posted in Java, JSP on May 16, 2010 by Joey

To get the web application root in a Java Server Page (JSP), use the getRealPath method of the application class, as demonstrated in the example below:

How to Install jQuery

Posted in JavaScript, jQuery on May 15, 2010 by Joey

Go to

Scroll down to the “Current Version” section.

Right-click on “Uncompressed” and select “Save Link As…”

Save the file to your local web root (somewhere like C:\wwwroot\js\)

Now that the file is downloaded, jQuery is ready to be included in your website. Include it with the standard script tag, then check for the existence of jQuery, as shown in the example below:

ExtJS Expand Tree Node Listener

Posted in ExtJS on May 13, 2010 by Joey

The listener for expanding a node in ExtJS is “expandnode”. This can be added to the “listeners” config of an ExtJS tree. Any code added to the expandnode section will run whenever a node is expanded in the tree. See example below.