Category: Java
Initialization of an ArrayList in one line example
This tutorials demonstrates how to initialize a list or arraylist in one line in different ways. The traditional way to create and initialize an ArrayList is: List<String> planets = new ArrayList<String>(); planets.add(“Earth”); planets.add(“Mars”); planets.add(“Venus”);...
How to Calculate Folder Size in Java
Calculating the size of a folder or directory is trivial. In Java you can recursively traverse each folder and calculate the size of each file individually, and return the sum of all the files....
Converting a String into a LocalDate – Java 8
This tutorial shows how to convert a java.lang.String into a java.time.LocalDate. We can convert a String into a Date using the parse() method of the LocalDate and DateTimeFormatter classes. // from java.lang.String into java.time.LocalDate...
Converting a String into a Date in Java
This tutorial shows how to convert a java.lang.String into a java.util.Date. We can convert a String into a Date using the parse() method of the DateFormat and SimpleDateFormat classes. // from java.lang.String into java.util.Date...
Getting Current Date and Time in Java
This tutorial shows how to get the current date and time in Java. The standard Java classes we can use are java.util.Date, java.util.Calendar and the new java 8 java.time.LocalDateTime and java.time.ZonedDateTime. You could also...
Monitor Tomcat with JMX and jConsole
This tutorial shows how to monitor Tomcat with JMX via jConsole. Monitoring is a key aspect for developers or system administrators. Looking inside a running server, obtaining some statistics like: Heap / Non-heap memory...
Calculate Age from date of birth in Java
This tutorial demonstrates how to calculate the age from a birth date in Java. Something trivial as calculating the age, was daunting before Joda Time and Java 8. Let’s list the options you have...
MySQL / MariaDb + Hibernate XML Configuration Example
This tutorial shows you how to configure MySQL/MariaDB with Hibernate using XML Configuration. We demonstrate this by inserting a POJO into the database. This POJO and database are configured using XML Configuration. Maven Dependencies...
Add, Edit Metadata of PDF Document using iText in Java
Metadata has been described as the business card of a particular digital document. The term metadata literally means “data about data”. It can contains additional information about a file. This includes, but not limits...