Home » Core Java » apache » commons » lang3

lang3

org.apache.commons.lang3.math.Fraction Example

Hi folks, Today we are going to talk about Fractions from org.apache.commons.lang3.math package. This api provides us with capabilities to handle operations on fractions. I wrote a nice and simple java program demonstrating the application of this api. If you are already a java programmer and if you have tried dividing two numbers with different datatypes, you would have encountered ...

Read More »

org.apache.commons.lang3.ClassPathUtils Example

In this example we are going to elaborate the use of the ClassPathUtils class in the package: org.apache.commons.lang3 or previouslyorg.apache.commons.lang, as the package name says, it is a member of the Apache Commons Lang, and deals with the classpaths. As like other classes of the Apache Commons This class also provides us with some really helpful methods. The methods of this ...

Read More »

org.apache.commons.lang3.CharUtils Example

In this example we are going to elaborate the use of the CharUtils class in the package: org.apache.commons.lang3 or previously org.apache.commons.lang, as the package name says, it is a member of the Apache Commons Lang, and deals with Character (char) Manipulation. As like other classes of the Apache Commons This class also provides us with some really helpful methods. The ...

Read More »

org.apache.commons.lang3.math.NumberUtils Example

Hey folks, this post is about a Math Package:NumberUtils.It has few handful of utility methods. All methods are static, so you don’t have to create an instance of it.  It resides in org.apache.commons.lang3.math.NumberUtils package. You can download the jar from http://commons.apache.org/proper/commons-lang/.               Or using Maven <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.3.2</version> and an import is necessary import ...

Read More »

org.apache.commons.lang3.StringUtils Example

In this example we are going to elaborate the use of the StringUtils class in the package: org.apache.commons.lang3.StringUtils or previously org.apache.commons.lang.StringUtils, as the package name says, it is a member of the Apache Commons Lang, and deals with String Manipulation. As like other classes of the Apache Commons This class also provides us with some really helpful methods. The methods of ...

Read More »

Check if Days and Calendars match

With this example we are going to demonstrate how to check if Days and Calendars match. We are using the org.apache.commons.lang3.time.DateUtils Class, that is a suite of utilities surrounding the use of the Calendar and Date object. DateUtils contains a lot of common methods considering manipulations of Dates or Calendars. In short, to check if Days and Calendars match you should: ...

Read More »

Capitalize words of a string

This is an example of how to capitalize the words of a String. We are using the org.apache.commons.lang3.text.WordUtils Class, that provides operations on Strings that contain words. The Class tries to handle null input gracefully. An exception will not be thrown for a null input. Trying to capitalize the words of a String implies that you should: Use capitalize(String str) API ...

Read More »

Generate random alphanumeric string

In this example we shall show you how to generate random alphanumeric String objects. We are using the org.apache.commons.lang3.RandomStringUtils class, that offers operations for random Strings. To generate random alphanumeric String objects one should perform the following steps: Use random(int count, boolean letters, boolean numbers) method to create a random string whose length is the number of characters specified. Use randomAlphabetic(int count) ...

Read More »

Date and Time format

With this example we are going to demonstrate how to make Date and Time formatting. We are using the org.apache.commons.lang3.time.DateFormatUtils class, that provides Date and time formatting utilities and constants. It uses the org.apache.commons.lang3.time.FastDateFormat class, that is a fast and thread-safe version of SimpleDateFormat. In short, to format Date and Time you should: Create a new Date object. Use ISO_DATETIME_FORMAT field ...

Read More »

Word counter

This is an example of how to count the words of a String paragraph, using the org.apache.commons.lang3.StringUtils class. This class provides operations on String that are null safe. Counting the words of a paragraph implies that you should: Create a String that is a paragraph. Create a String word that is the word to search in the paragraph. Use the countMatches ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns