SECURITY / CATATAN</>↗Security16 Mei 2016
package org.kodejava.security; import java.security.SecureRandom; import java.util.Random; public class RandomString { public static final String SOURCES = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"; public static void main(String[] args) { RandomString rs = new RandomString(); System.out.println(rs.generateString(new Random(), SOURCES, 10)); System.out.println(rs.generateString(new Random(), SOURCES, 10)); System.out.println(rs.generateString(new Secure...
CORE API / CATATAN</>↗Core API18 Mar 2016
Usually, if not always, we use the if statement combined with == or != operators to check if an object reference is null or not. We do this to validate arguments passed to constructors or methods doesn’t contain a null value. These null check can be seen as clutter in our code. The solution is […]
JAVA DATE TIME API / CATATAN</>↗Java Date Time API09 Mar 2016
In this example we are going to learn how to implement a custom TemporalAdjuster. We are going to create TemporalAdjuster to find the next working day from a specified date. We will use 5 working days, from Monday to Friday. The custom temporal adjuster class should implement the TemporalAdjuster interface, which define a single method […]
CORE API / CATATAN</>↗Core API07 Mar 2016
In this example we are going to learn to use a java.util.Formatter to format negative number in parentheses. The Formatter can use a format flags to format a value. To display a negative number in parentheses we can use the ( flag. This flag display negative number inside parentheses instead of using the – symbol. […]
JAVA 8 / CATATAN</>↗Java 806 Mar 2016
In the previous example we manipulate the value of LocalDate by adding or subtracting the value of date object by days, months, years using methods like plusMonths() or minusDays(). Or by changing the year or the month of the date object using methods like withYear() or withMonth(). But there are times that we want to […]
MAVEN / CATATAN</>↗Maven29 Feb 2016
Sometimes when the required libraries / dependencies is not available in the Maven Central Repository we need to manually install it to our local repository. This library must be placed in the correct directory in our local repository to enable Maven to find it. The default location is under the ${user.home}/.m2/repository. To make this job […]