Archive For April 19, 2017

Convert string to date in java

By |

try { Date date = new Date(); Calendar cal = Calendar.getInstance(); cal.set(2017, 04, 08); int startYear = cal.get(Calendar.YEAR); int startMonth = cal.get(Calendar.MONTH); int startDay = cal.get(Calendar.DAY_OF_MONTH); System.out.println(“date year ” + startYear); System.out.println(“date month ” + startMonth); System.out.println(“date day ” + startDay); cal.setTime(date); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH); int day = cal.get(Calendar.DAY_OF_MONTH); System.out.println(“date…

Read more »