APACHE POI / CATATAN</>↗Apache POI05 Feb 2016
The code snippet below show you how you can replace string in Microsoft Word document using the Apache POI library. The class below have three method, the openDocument(), saveDocument() and replaceText(). The routine for replacing text is implemented in the replaceText() method. This method take the HWPFDocument, the String to find and the String to […]
CORE API / CATATAN</>↗Core API04 Feb 2016
The code snippet below show us how to display or format negative number in parentheses. We start by defining the number format, the pattern has two parts separated by a semicolon. In the snippet we use the #,##0.00;(#,##0.00) pattern. The pattern after the semicolon will be used to format negative number. Next we create an […]
JAVA 8 / CATATAN</>↗Java 831 Jan 2016
In this example we will learn how to convert the old java.util.Date and java.util.Calendar objects to the new Date Time introduced in Java 8. The first method in the code snippet below dateToNewDate() show conversion of java.util.Date while the calendarToNewDate() show the conversion of java.util.Calendar. The java.util.Date and java.util.Calendar provide a toInstant() method to convert […]
JAVA 8 / CATATAN</>↗Java 831 Jan 2016
In this example we will learn how to get the date of the first particular day that fall after a specific date. In the code snippet below we will find the first Friday that fall after the new year of 2021. First let’s create a LocalDate object that represent the new year of 2021. We […]
JAVA DATE TIME API / CATATAN</>↗Java Date Time API29 Jan 2016
The new Java 8 java.time.LocalDate class provide a plus() and minus() methods to add or subtract an amount of period to or from the LocalDate object. The period is represented using the java.time.Period class. To create an instance of Period we can use the of(), ofDays(), ofWeeks(), ofMonths() and ofYears() methods. Let’s see an example […]
JAVA 8 / CATATAN</>↗Java 821 Jan 2016
In this example you’ll learn how to use the java.time.Period class (from Java 8) to calculate difference between two dates. Using Period.between() method will give us difference between two dates in years, months and days period. Beside using the Period class, we also use the ChronoUnit enum to calculate difference between two dates. We use […]