Creating java date object from year,month,day
java.time
Using java.time
framework built into Java 8
int year = 2015;int month = 12;int day = 22;LocalDate.of(year, month, day); //2015-12-22LocalDate.parse("2015-12-22"); //2015-12-22//with custom formatter DateTimeFormatter.ofPattern formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");LocalDate.parse("22-12-2015", formatter); //2015-12-22
If you need also information about time(hour,minute,second) use some conversion from LocalDate
to LocalDateTime
LocalDate.parse("2015-12-22").atStartOfDay() //2015-12-22T00:00