CORE API / CATATAN</>↗Core API18 Agt 2006
In the following example we are going to calculate the differences between two dates. First, we will need to convert the date into the corresponding value in milliseconds and then do the math, so we can get the difference in days, hours, minutes, etc. For example to get the difference in day we will need […]
APACHE COMMONS / CATATAN</>↗Apache Commons13 Agt 2006
package org.kodejava.commons.lang; import org.apache.commons.lang3.StringUtils; public class WordCountDemo { public static void main(String[] args) { // We have the source text we'll do the search on. String source = "From the download page, you can download the Java " + "Tutorials for browsing offline. Or you can just download " + "the example."; // The word […]
APACHE COMMONS / CATATAN</>↗Apache Commons09 Agt 2006
package org.kodejava.commons.lang; import org.apache.commons.lang3.StringUtils; public class StringReverseDemo { public static void main(String[] args) { // We have an original string here that we'll need to reverse. String words = "The quick brown fox jumps over the lazy dog"; // Using StringUtils.reverse we can reverse the string letter by letter. String reversed = StringUtils.reverse(words); // Now […]
APACHE COMMONS / CATATAN</>↗Apache Commons05 Agt 2006
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 […]
CORE API / CATATAN</>↗Core API04 Agt 2006
package org.kodejava.text; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.Calendar; import java.util.Date; public class DateToString { public static void main(String[] args) { // Create an instance of SimpleDateFormat used for formatting // the string representation of date (day/month/year) String pattern = "dd/MM/yyyy"; DateFormat df = new SimpleDateFormat(pattern); // Ge...
CORE API / CATATAN</>↗Core API30 Jul 2006
In this example we want to create a calendar or date from a year and day of the year. Next we will find out what day-of-week that calendar or date represent. In the code snippet below we are trying to find the 180 day of the year 2021. Let’s see the example below. package org.kodejava.util; […]