SupportWriter space ↗
A JOURNAL ABOUT TECHNOLOGY

Learn something new.
Write. Share.

A space to connect knowledge, one line of code a day.
Discover tutorials, ideas, and notes from a learning journey.

1967 notes & counting ↙
FOR YOUR CURIOSITY

Latest notes.

APACHE COMMONS / NOTES</>↗
Apache Commons20 Oct 2007

How do I check for an empty string?

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 […]

Wayan · 2 min read
APACHE COMMONS / NOTES</>↗
Apache Commons19 Oct 2007

How do I get the nearest hour, minute, second of a date?

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_...

Wayan · 2 min read
APACHE COMMONS / NOTES</>↗
Apache Commons19 Oct 2007

How do I format date and time using DateFormatUtils class?

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 […]

Wayan · 2 min read
APACHE COMMONS / NOTES</>↗
Apache Commons14 Oct 2007

How do I find specific elements or object in an array?

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 […]

Wayan · 2 min read
APACHE COMMONS / NOTES</>↗
Apache Commons10 Oct 2007

How do I use CompareToBuilder class?

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. […]

Wayan · 2 min read
APACHE COMMONS / NOTES</>↗
Apache Commons10 Oct 2007

How do I use ReflectionToStringBuilder class?

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 […]

Wayan · 2 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.