APACHE COMMONS / NOTES</>↗Apache Commons31 Oct 2007
In this example you’ll see how to read an indexed property of an object such as List or array. Using the PropertyUtils.getIndexedProperty() method we can do it easily. This method take the bean and the name of indexed property including the element to be read. Let’s see the example below for more details. package org.kodejava.commons.beanutils; […]
APACHE COMMONS / NOTES</>↗Apache Commons27 Oct 2007
In this example you’ll see how to read bean’s nested property, we’ll use PropertyUtils.getNestedProperty() method. To test we will create three classes, Track and Artist for our beans and ReadNestedProperty as a main program to run. The Track class will contain a property of an Artist object. Using the PropertyUtils.getNestedProperty() method we want to get […]
APACHE COMMONS / NOTES</>↗Apache Commons27 Oct 2007
In this example we will learn how to use PropertyUtils.getSimpleProperty() method to read bean’s property value. To test this method we will create a simple class called Track for our bean. The Track class have some properties such as id, title and duration. The PropertyUtils.getSimpleProperty() reads our bean property by accessing the bean’s getter method. […]
APACHE COMMONS / NOTES</>↗Apache Commons24 Oct 2007
In this example we’ll use the StringUtils.substringBetween() method. Here we’ll extract the title and body of our HTML document. Let’s see the code. package org.kodejava.commons.lang; import java.util.Date; import org.apache.commons.lang3.StringUtils; public class NestedString { public static void main(String[] args) { String helloHtml = "<html>" + "<head>" + " <title>Hello World from Java</title>" + "<body>" + "Hello, […]
APACHE COMMONS / NOTES</>↗Apache Commons20 Oct 2007
package org.kodejava.commons.lang; import org.apache.commons.lang3.StringUtils; public class EmptyStringCheckDemo { public static void main(String[] args) { // Create some variable to hold some empty string, contains only // whitespaces and words. String one = ""; String two = "\t\r\n"; String three = " "; String four = null; String five = "four four two"; // We can […]
APACHE COMMONS / NOTES</>↗Apache Commons19 Oct 2007
This example demonstrates how to use the DateUtils.round() method to get the nearest hour, minute and second of a date. package org.kodejava.commons.lang; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.FastDateFormat; import java.util.Calendar; import java.util.Date; public class DateRoundingDemo { public static void main(String[] args) { FastDateFormat formatter = DateFormatUtils.ISO_...