CORE API / CATATAN</>↗Core API24 Feb 2006
To get the current month name from the system we can use java.util.Calendar class. The Calendar.get(Calendar.MONTH) returns the month value as an integer starting from 0 as the first month and 11 as the last month. This mean January equals to 0, February equals to 1 and December equals to 11. Let’s see the code […]
CORE API / CATATAN</>↗Core API20 Feb 2006
When building a computer program we will use a lot of string to represent our data. The data might not just information about our customer name, email or address, but will also contain numeric data represented as string. So how do we know if this string contains a valid number? Java provides some wrappers to […]
CORE API / CATATAN</>↗Core API19 Feb 2006
What date, month, year, day-of-week, day-of-month, day-of-year is it today? If we want to answer these question we can use java.util.Calendar and java.util.GregorianCalendar which is the implementation of Calendar abstract class. These classes can help us to get integer value such as date, month, year from a Date object. Let’s see the example code. package […]
CORE API / CATATAN</>↗Core API18 Feb 2006
To get the minimum or maximum value of a primitive data types such as byte, short, int, long, float and double we can use the wrapper class provided for each of them, the wrapper classes are Byte, Short, Integer, Long, Float and Double which is located in java.lang package. package org.kodejava.lang; public class MinMaxExample { […]
CORE API / CATATAN</>↗Core API17 Feb 2006
The following code shows how we can convert a string representation of date into java.util.Date object. To convert a string of date we can use the help from java.text.SimpleDateFormat that extends java.text.DateFormat abstract class. package org.kodejava.text; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.Date; public class ConvertStringTo...
CORE API / CATATAN</>↗Core API13 Feb 2006
Using Arrays.equals() methods we can compare if two arrays are equal. Two arrays are considered to be equal if their length, each element in both arrays are equal and in the same order to one another. package org.kodejava.util; import java.util.Arrays; public class CompareArrayExample { public static void main(String[] args) { String[] abc = {"Kode", "Java", […]