With java 8, you can easily manage that in LocalDate
LocalDate today = LocalDate.now();
int thisYear = today.getYear();
int thisMonth = today.getMonthValue();
int thisDay = today.getDayOfMonth();
out.println(thisYear + "-" + thisMonth + "-" + thisDay);
But when you try to achieve more (hours, minutes, seconds), you then can turn to LocalDateTime
LocalDateTime curMoment = LocalDateTime.now();
thisYear = curMoment.getYear();
thisMonth = curMoment.getMonthValue();
thisDay = curMoment.getDayOfMonth();
int thisHour = curMoment.getHour();
int thisMinute = curMoment.getMinute();
int thisSecond = curMoment.getSecond();
System.out.println(thisYear + "-" + thisMonth + "-" + thisDay + " " + thisHour + ":" + thisMinute + ":" + thisSecond);
And then the output will be:+
2018-7-4
2018-7-4 14:33:12