Date date = new Date(); System.out.println(date.toString()); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); System.out.println(format.format(date)); String input = "1818-11-11 23:12:34"; SimpleDateFormat f1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { // System.out.println(f1.parse(input)); Date date2 = f1.parse(input); System.out.println(date2); } catch (ParseException e) { e.printStackTrace(); } Calendar calendar = Calendar.getInstance(); calendar.set(2019, 9, 12); System.out.println(calendar.get(Calendar.YEAR)); System.out.println(calendar.get(Calendar.MONDAY)); System.out.println(calendar.get(Calendar.DATE)); System.out.println(calendar.get(Calendar.DAY_OF_MONTH)); System.out.println(calendar.get(Calendar.DAY_OF_WEEK)); calendar.add(Calendar.DATE, 30); System.out.println(calendar.get(Calendar.YEAR)); System.out.println(calendar.get(Calendar.MONDAY)); System.out.println(calendar.get(Calendar.DATE)); System.out.println(calendar.get(Calendar.DAY_OF_MONTH)); System.out.println(calendar.get(Calendar.DAY_OF_WEEK));