APACHE COMMONS / NOTES</>↗Apache Commons19 Oct 2007
The DateFormatUtils class help us to format date and time information. This class uses an instance of org.apache.commons.lang3.time.FastDateFormat class to format the date and time information. Compared to Java SimpleDateFormat, the FastDateFormat class is thread safe. If you want to create a custom date format, you can use the FastDateFormat class directly. package org.kodejava.commons.lang; import […]
APACHE COMMONS / NOTES</>↗Apache Commons14 Oct 2007
This example demonstrates how to find specific items in an array. We will use the org.apache.commons.lang3.ArrayUtils class. This class provides method called contains(Object[] array, Object objectToFind) method to check if an array contains the objectToFind in it. We can also use the indexOf(Object[] array, Object objectToFind) method and the lastIndexOf(Object[] array, Object objectToFind) method to […]
APACHE COMMONS / NOTES</>↗Apache Commons10 Oct 2007
This example show how we can use the CompareToBuilder class for automatically create an implementation of compareTo(Object o) method. Please remember, when you are implementing this method, you will also need to implement the equals(Object o) method consistently. This will make sure the behavior of your class is consistent in relation to collection sorting processes. […]
APACHE COMMONS / NOTES</>↗Apache Commons10 Oct 2007
Implementing toString() method sometimes can become a time-consuming process. If you have a class with a few fields, it might be alright. However, when you deal with a lot of fields, it will surely take some time to update this method every time a new field comes and goes. Here comes the ReflectionToStringBuilder class that […]
CORE API / NOTES</>↗Core API07 Oct 2007
The Integer.getInteger() methods allows us to easily read system property and convert it directly to Integer object. This method call the System.getProperty() method and then convert it to integer by calling the Integer.decode() method. package org.kodejava.lang; public class IntegerProperty { public static void main(String[] args) { // Add properties to the system. In this example […]
CORE API / NOTES</>↗Core API04 Oct 2007
The static Integer.decode() method can be used to convert a string representation of a number into an Integer object. Under the cover this method call the Integer.valueOf(String s, int radix). The string can start with the optional negative sign followed with radix specified such as 0x, 0X, # for hexadecimal value, 0 (zero) for octal […]