Joda Time LocalDate by Examples in Java
Tags: Joda Time DateTime DateTimeZone LocalDate LocalDateTime LocalTime Instant Calendar Date DateTimeFieldType DurationFieldType Interval Period Chronology GregorianChronology Joda DateTime Joda DateTimeZone Joda LocalDate Joda LocalDateTime Joda LocalTime Joda Instant Joda DateTimeFieldType Joda DurationFieldType Joda Interval Joda Period Joda Chronology Joda GregorianChronology
In this Java tutorial, we learn how to use the org.joda.time.LocalDate class of Joda Time library by different example Java programs.
Add Joda Time library to your Java project
To use Joda Time Java library in the Gradle build project, add the following dependency into the build.gradle file.
compile group: 'joda-time', name: 'joda-time', version: '2.10.9'
To use Joda Time Java library in the Maven build project, add the following dependency into the pom.xml file.
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.9</version>
</dependency>
To download the Joda Time .jar file you can visit Joda Time releases page at github.com/JodaOrg/joda-time
How to create LocalDate object using constructors
The following Java example program, we use default constructor to create a current local date object or with a specified timezone, chronology.
JodaTimeLocalDateExample1.java
import org.joda.time.Chronology;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
import org.joda.time.chrono.GregorianChronology;
public class JodaTimeLocalDateExample1 {
public static void main(String[] args) {
DateTimeZone dateTimeZone = DateTimeZone.forID("Europe/London");
Chronology chronology = GregorianChronology.getInstance();
LocalDate localDate1 = new LocalDate();
LocalDate localDate2 = new LocalDate(dateTimeZone);
LocalDate localDate3 = new LocalDate(chronology);
System.out.println(localDate1);
System.out.println(localDate2);
System.out.println(localDate3);
}
}
2021-01-15
2021-01-15
2021-01-15
In the following example we create a LocalDate object from a given milliseconds.
JodaTimeLocalDateExample2.java
import org.joda.time.Chronology;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
import org.joda.time.chrono.GregorianChronology;
public class JodaTimeLocalDateExample2 {
public static void main(String[] args) {
DateTimeZone dateTimeZone = DateTimeZone.forID("Europe/London");
Chronology chronology = GregorianChronology.getInstance();
int milliseconds = 1000;
LocalDate localDate1 = new LocalDate(milliseconds);
LocalDate localDate2 = new LocalDate(milliseconds, dateTimeZone);
LocalDate localDate3 = new LocalDate(milliseconds, chronology);
System.out.println(localDate1);
System.out.println(localDate2);
System.out.println(localDate3);
}
}
1970-01-01
1970-01-01
1970-01-01
From a given Instant object we can create a new LocalDate object.
JodaTimeLocalDateExample3.java
import org.joda.time.Chronology;
import org.joda.time.DateTimeZone;
import org.joda.time.Instant;
import org.joda.time.LocalDate;
import org.joda.time.chrono.GregorianChronology;
public class JodaTimeLocalDateExample3 {
public static void main(String[] args) {
DateTimeZone dateTimeZone = DateTimeZone.forID("Europe/London");
Chronology chronology = GregorianChronology.getInstance();
Instant instant = new Instant();
LocalDate localDate1 = new LocalDate(instant);
LocalDate localDate2 = new LocalDate(instant, dateTimeZone);
LocalDate localDate3 = new LocalDate(instant, chronology);
System.out.println(localDate1);
System.out.println(localDate2);
System.out.println(localDate3);
}
}
2021-01-15
2021-01-15
2021-01-15
We also can create LocalDate objects with given day, month, year values.
JodaTimeLocalDateExample4.java
import org.joda.time.Chronology;
import org.joda.time.LocalDate;
import org.joda.time.chrono.GregorianChronology;
public class JodaTimeLocalDateExample4 {
public static void main(String[] args) {
Chronology chronology = GregorianChronology.getInstance();
int year = 2021;
int monthOfYear = 1;
int dayOfMonth = 1;
LocalDate localDate1 = new LocalDate(year, monthOfYear, dayOfMonth);
LocalDate localDate2 = new LocalDate(year, monthOfYear, dayOfMonth, chronology);
System.out.println(localDate1);
System.out.println(localDate2);
}
}
2021-01-01
2021-01-01
How to use LocalDate.now() static method to create new LocalDate object
JodaTimeLocalDateExample5.java
import org.joda.time.Chronology;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
import org.joda.time.chrono.GregorianChronology;
public class JodaTimeLocalDateExample5 {
public static void main(String[] args) {
DateTimeZone dateTimeZone = DateTimeZone.forID("Europe/London");
Chronology chronology = GregorianChronology.getInstance();
LocalDate localDate1 = LocalDate.now();
LocalDate localDate2 = LocalDate.now(dateTimeZone);
LocalDate localDate3 = LocalDate.now(chronology);
System.out.println(localDate1);
System.out.println(localDate2);
System.out.println(localDate3);
}
}
2021-01-15
2021-01-15
2021-01-15
Parse a String to Joda Time LocalDate
JodaTimeLocalDateExample6.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample6 {
public static void main(String[] args) {
LocalDate localDate = LocalDate.parse("2021-01-01");
System.out.println(localDate);
}
}
2021-01-01
Create LocalDate from a java.util.Calendar object
In the following Java program, we use LocalDate.fromCalendarFields() static method to create LocalDate object from a Calendar object.
JodaTimeLocalDateExample7.java
import org.joda.time.LocalDate;
import java.util.Calendar;
public class JodaTimeLocalDateExample7 {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
LocalDate localDate = LocalDate.fromCalendarFields(calendar);
System.out.println(localDate);
}
}
2021-01-15
Create LocalDate from a java.util.Date object
In the following Java program, we use LocalDate.fromDateFields() static method to create a new LocalDate object from a Date value.
JodaTimeLocalDateExample8.java
import org.joda.time.LocalDate;
import java.util.Date;
public class JodaTimeLocalDateExample8 {
public static void main(String[] args) {
Date date = new Date();
LocalDate localDate = LocalDate.fromDateFields(date);
System.out.println(localDate);
}
}
2021-01-15
How to get fields value of a LocalDate object
The following Java program to show how to get day, month, year values using LocalDate.get() method.
JodaTimeLocalDateExample9.java
import org.joda.time.DateTimeFieldType;
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample9 {
public static void main(String[] args) {
LocalDate localDate = new LocalDate();
int year = localDate.get(DateTimeFieldType.year());
int monthOfYear = localDate.get(DateTimeFieldType.monthOfYear());
int dayOfMonth = localDate.get(DateTimeFieldType.dayOfMonth());
System.out.println(year);
System.out.println(monthOfYear);
System.out.println(dayOfMonth);
}
}
2021
1
15
JodaTimeLocalDateExample10.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample10 {
public static void main(String[] args) {
LocalDate localDate = new LocalDate();
int dayOfWeek = localDate.getDayOfWeek();
int dayOfMonth = localDate.getDayOfMonth();
int dayOfYear = localDate.getDayOfYear();
int weekOfWeekyear = localDate.getWeekOfWeekyear();
int weekYear = localDate.getWeekyear();
int monthOfYear = localDate.getMonthOfYear();
int year = localDate.getYear();
System.out.println("Day of week: " + dayOfWeek);
System.out.println("Day of month: " + dayOfMonth);
System.out.println("Day of year: " + dayOfYear);
System.out.println("Week of week year: " + weekOfWeekyear);
System.out.println("Week year: " + weekYear);
System.out.println("Month of year: " + monthOfYear);
System.out.println("Year: " + year);
}
}
Day of week: 5
Day of month: 15
Day of year: 15
Week of week year: 2
Week year: 2021
Month of year: 1
Year: 2021
Convert LocalDate to Date using toDate() method
JodaTimeLocalDateExample11.java
import org.joda.time.LocalDate;
import java.util.Date;
public class JodaTimeLocalDateExample11 {
public static void main(String[] args) {
LocalDate localDate = new LocalDate();
Date date = localDate.toDate();
System.out.println(localDate);
System.out.println(date);
}
}
2021-01-15
Fri Jan 15 00:00:00 ICT 2021
Convert LocalDate to LocalDateTime using toLocalDateTime() method
JodaTimeLocalDateExample12.java
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
import org.joda.time.LocalTime;
public class JodaTimeLocalDateExample12 {
public static void main(String[] args) {
LocalDate localDate = new LocalDate();
LocalDateTime localDateTime = localDate.toLocalDateTime(new LocalTime());
System.out.println(localDate);
System.out.println(localDateTime);
}
}
2021-01-15
2021-01-15T22:57:37.943
Convert LocalDate to DateTime
Using toDateTimeAtCurrentTime() method
JodaTimeLocalDateExample13.java
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample13 {
public static void main(String[] args) {
DateTimeZone dateTimeZone = DateTimeZone.forID("Europe/London");
LocalDate localDate = new LocalDate();
DateTime dateTime1 = localDate.toDateTimeAtCurrentTime();
DateTime dateTime2 = localDate.toDateTimeAtCurrentTime(dateTimeZone); // with a date time zone
System.out.println(localDate);
System.out.println(dateTime1);
System.out.println(dateTime2);
}
}
2021-01-15
2021-01-15T22:58:25.284+07:00
2021-01-15T15:58:25.284Z
Using toDateTimeAtStartOfDay() method
JodaTimeLocalDateExample14.java
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample14 {
public static void main(String[] args) {
DateTimeZone dateTimeZone = DateTimeZone.forID("Europe/London");
LocalDate localDate = new LocalDate();
DateTime dateTime1 = localDate.toDateTimeAtStartOfDay();
DateTime dateTime2 = localDate.toDateTimeAtStartOfDay(dateTimeZone);
System.out.println(localDate);
System.out.println(dateTime1);
System.out.println(dateTime2);
}
}
2021-01-15
2021-01-15T00:00:00.000+07:00
2021-01-15T00:00:00.000Z
Using toDateTime() method
JodaTimeLocalDateExample15.java
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.Instant;
import org.joda.time.LocalDate;
import org.joda.time.LocalTime;
public class JodaTimeLocalDateExample15 {
public static void main(String[] args) {
DateTimeZone dateTimeZone = DateTimeZone.forID("Europe/London");
LocalTime localTime = new LocalTime();
Instant instant = new Instant();
LocalDate localDate = new LocalDate();
DateTime dateTime1 = localDate.toDateTime(localTime);
DateTime dateTime2 = localDate.toDateTime(localTime, dateTimeZone);
DateTime dateTime3 = localDate.toDateTime(instant);
System.out.println(localDate);
System.out.println(dateTime1);
System.out.println(dateTime2);
System.out.println(dateTime3);
}
}
2021-01-15
2021-01-15T22:59:21.874+07:00
2021-01-15T22:59:21.874Z
2021-01-15T15:59:21.884Z
Convert LocalDate to Interval using toInterval() method
JodaTimeLocalDateExample16.java
import org.joda.time.DateTimeZone;
import org.joda.time.Interval;
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample16 {
public static void main(String[] args) {
DateTimeZone dateTimeZone = DateTimeZone.forID("Europe/London");
LocalDate localDate = new LocalDate();
Interval interval1 = localDate.toInterval();
Interval interval2 = localDate.toInterval(dateTimeZone);
System.out.println(localDate);
System.out.println(interval1);
System.out.println(interval2);
}
}
2021-01-15
2021-01-15T00:00:00.000+07:00/2021-01-16T00:00:00.000+07:00
2021-01-15T00:00:00.000Z/2021-01-16T00:00:00.000Z
Convert LocalDate to String using toString() method
JodaTimeLocalDateExample17.java
import org.joda.time.LocalDate;
import java.util.Locale;
public class JodaTimeLocalDateExample17 {
public static void main(String[] args) {
LocalDate localDate = new LocalDate();
String value1 = localDate.toString();
String value2 = localDate.toString("DD/MM/yyyy");
String value3 = localDate.toString("DD, MMMM, yyyy", Locale.CANADA);
System.out.println(value1);
System.out.println(value2);
System.out.println(value3);
}
}
2021-01-15
15/01/2021
15, January, 2021
How to compare LocalDate values
JodaTimeLocalDateExample18.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample18 {
public static void main(String[] args) {
LocalDate localDate1 = new LocalDate(2021, 1, 1);
LocalDate localDate2 = new LocalDate(2021, 1, 2);
LocalDate localDate3 = new LocalDate(2021, 1, 1);
System.out.println("localDate1: " + localDate1);
System.out.println("localDate2: " + localDate2);
System.out.println("localDate3: " + localDate3);
System.out.println("localDate1 compare to localDate2: " + localDate1.compareTo(localDate2));
System.out.println("localDate1 compare to localDate3: " + localDate1.compareTo(localDate3));
System.out.println("localDate2 compare to localDate1: " + localDate2.compareTo(localDate1));
System.out.println("localDate3 compare to localDate1: " + localDate3.compareTo(localDate1));
System.out.println("localDate1 equals localDate2: " + localDate1.equals(localDate2));
System.out.println("localDate1 equals localDate3: " +localDate1.equals(localDate3));
}
}
localDate1: 2021-01-01
localDate2: 2021-01-02
localDate3: 2021-01-01
localDate1 compare to localDate2: -1
localDate1 compare to localDate3: 0
localDate2 compare to localDate1: 1
localDate3 compare to localDate1: 0
localDate1 equals localDate2: false
localDate1 equals localDate3: true
How to use withDayOfWeek() method
JodaTimeLocalDateExample19.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample19 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate mondayThisWeek = today.withDayOfWeek(1);
LocalDate tuesdayThisWeek = today.withDayOfWeek(2);
LocalDate wednesdayThisWeek = today.withDayOfWeek(3);
LocalDate thursdayThisWeek = today.withDayOfWeek(4);
LocalDate fridayThisWeek = today.withDayOfWeek(5);
LocalDate saturdayThisWeek = today.withDayOfWeek(6);
LocalDate sundayThisWeek = today.withDayOfWeek(7);
System.out.println(today);
System.out.println(mondayThisWeek);
System.out.println(tuesdayThisWeek);
System.out.println(wednesdayThisWeek);
System.out.println(thursdayThisWeek);
System.out.println(fridayThisWeek);
System.out.println(saturdayThisWeek);
System.out.println(sundayThisWeek);
}
}
2021-01-15
2021-01-11
2021-01-12
2021-01-13
2021-01-14
2021-01-15
2021-01-16
2021-01-17
How to use withDayOfMonth() method
JodaTimeLocalDateExample20.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample20 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate firstDayOfThisMonth = today.withDayOfMonth(1);
System.out.println(today);
System.out.println(firstDayOfThisMonth);
}
}
2021-01-15
2021-01-01
How to use withDayOfYear() method
JodaTimeLocalDateExample21.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample21 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate day69OfThisYear = today.withDayOfYear(69);
System.out.println(today);
System.out.println(day69OfThisYear);
}
}
2021-01-15
2021-03-10
How to use withWeekOfWeekyear() method
JodaTimeLocalDateExample22.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample22 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate thirdWeekOfThisYear = today.withWeekOfWeekyear(3);
System.out.println(today);
System.out.println(thirdWeekOfThisYear);
}
}
2021-01-15
2021-01-22
How to use withMonthOfYear() method
JodaTimeLocalDateExample23.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample23 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate thisDayInMay = today.withMonthOfYear(5);
System.out.println(today);
System.out.println(thisDayInMay);
}
}
2021-01-15
2021-05-15
How to use withWeekyear() method
JodaTimeLocalDateExample24.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample24 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate localDate = today.withWeekyear(1999);
System.out.println(today);
System.out.println(localDate);
}
}
2021-01-15
1999-01-15
How to use withYear() method
JodaTimeLocalDateExample25.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample25 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
int nextYear = today.getYear() + 1;
LocalDate todayNextYear = today.withYear(nextYear);
System.out.println(today);
System.out.println(todayNextYear);
}
}
2021-01-15
2022-01-15
How to use withYearOfCentury() method
JodaTimeLocalDateExample26.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample26 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate middleOfCentury = today.withYearOfCentury(50);
System.out.println(today);
System.out.println(middleOfCentury);
}
}
2021-01-15
2050-01-15
How to use withYearOfEra() method
JodaTimeLocalDateExample27.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample27 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate thirdYear = today.withYearOfEra(3);
System.out.println(today);
System.out.println(thirdYear);
}
}
2021-01-15
0003-01-15
How to use withCenturyOfEra() method
JodaTimeLocalDateExample28.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample28 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate secondCenturyOfEra = today.withCenturyOfEra(2);
System.out.println(today);
System.out.println(secondCenturyOfEra);
}
}
2021-01-15
0221-01-15
How to use withFieldAdded() method
JodaTimeLocalDateExample29.java
import org.joda.time.DurationFieldType;
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample29 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate tomorrow = today.withFieldAdded(DurationFieldType.days(), 1);
LocalDate nextWeek = today.withFieldAdded(DurationFieldType.weeks(), 1);
LocalDate lastMonth = today.withFieldAdded(DurationFieldType.months(), -1);
System.out.println(today);
System.out.println(tomorrow);
System.out.println(nextWeek);
System.out.println(lastMonth);
}
}
2021-01-15
2021-01-16
2021-01-22
2020-12-15
How to use withField() method
JodaTimeLocalDateExample30.java
import org.joda.time.DateTimeFieldType;
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample30 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate firstDayOfWeek = today.withField(DateTimeFieldType.dayOfWeek(), 1);
LocalDate firstDayOfMonth = today.withField(DateTimeFieldType.dayOfMonth(), 1);
LocalDate firstDayOfYear = today.withField(DateTimeFieldType.dayOfYear(), 1);
System.out.println(today);
System.out.println(firstDayOfWeek);
System.out.println(firstDayOfMonth);
System.out.println(firstDayOfYear);
}
}
2021-01-15
2021-01-11
2021-01-01
2021-01-01
How to use minusDays() method
JodaTimeLocalDateExample31.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample31 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate yesterday = today.minusDays(1);
System.out.println(today);
System.out.println(yesterday);
}
}
2021-01-15
2021-01-14
How to use minusWeeks() method
JodaTimeLocalDateExample32.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample32 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate lastTwoWeeks = today.minusWeeks(2);
System.out.println(today);
System.out.println(lastTwoWeeks);
}
}
2021-01-15
2021-01-01
How to use minusMonths() method
JodaTimeLocalDateExample33.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample33 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate lastThreeMonths = today.minusMonths(3);
System.out.println(today);
System.out.println(lastThreeMonths);
}
}
2021-01-15
2020-10-15
How to use minusYears() method
JodaTimeLocalDateExample34.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample34 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate lastYear = today.minusYears(1);
System.out.println(today);
System.out.println(lastYear);
}
}
2021-01-15
2020-01-15
How to use minus() method
JodaTimeLocalDateExample35.java
import org.joda.time.LocalDate;
import org.joda.time.Period;
public class JodaTimeLocalDateExample35 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
Period oneYear = new Period(1, 0, 0, 0, 0, 0, 0, 0);
LocalDate lastYear = today.minus(oneYear);
System.out.println(today);
System.out.println(lastYear);
}
}
2021-01-15
2020-01-15
How to use plusDays() method
JodaTimeLocalDateExample36.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample36 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate tomorrow = today.plusDays(1);
System.out.println(today);
System.out.println(tomorrow);
}
}
2021-01-15
2021-01-16
How to use plusWeeks() method
JodaTimeLocalDateExample37.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample37 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate nextWeek = today.plusWeeks(1);
System.out.println(today);
System.out.println(nextWeek);
}
}
2021-01-15
2021-01-22
How to use plusMonths() method
JodaTimeLocalDateExample38.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample38 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate nextTwoMonths = today.plusMonths(2);
System.out.println(today);
System.out.println(nextTwoMonths);
}
}
2021-01-15
2021-03-15
How to use plusYears() method
JodaTimeLocalDateExample39.java
import org.joda.time.LocalDate;
public class JodaTimeLocalDateExample39 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate nextYear = today.plusYears(1);
System.out.println(today);
System.out.println(nextYear);
}
}
2021-01-15
2022-01-15
How to use plus() method
JodaTimeLocalDateExample40.java
import org.joda.time.LocalDate;
import org.joda.time.Period;
public class JodaTimeLocalDateExample40 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
Period oneMonth = new Period(0, 1, 0, 0, 0, 0, 0, 0);
LocalDate nextMonth = today.plus(oneMonth);
System.out.println(today);
System.out.println(nextMonth);
}
}
2021-01-15
2021-02-15
Happy Coding 😊
Related Articles
Joda Time Instant by Examples in Java
Joda Time LocalTime by Examples in Java
Joda Time LocalDateTime by Examples in Java
Joda Time DateTime by Examples in Java
Joda Time Duration by Examples in Java