### Question:
DateUtils { public static Calendar getDateFromString (String str, String format) { Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat(format); try { cal.setTime(sdf.parse(str)); } catch (ParseException e) { LogDelegate.e("Malformed datetime string" + e.getMessage()); } catch (NullPointerException e) { LogDelegate.e("Date or time not set"); } return cal; } private  DateUtils(); static String getString(long date, String format); static String getString(Date d, String format); static Calendar getDateFromString(String str, String format); static Calendar getLongFromDateTime(String date, String dateFormat, String time, String timeFormat); static Calendar getCalendar(Long dateTime); static String getLocalizedDateTime(Context mContext,
      String dateString, String format); static boolean is24HourMode(Context mContext); static boolean isSameDay(long date1, long date2); static long getNextMinute(); static long getPresetReminder(Long currentReminder); static Long getPresetReminder(String alarm); static boolean isFuture(String timestamp); static boolean isFuture(Long timestamp); static String prettyTime(String timeInMillisec); static String prettyTime(Long timeInMillisec);  }### Answer:
@Test public void getDateFromStringTest(){ String date="2020/03/12 15:15:15"; String dateformat="yyyy/MM/dd HH:mm:ss"; Calendar calendar=DateUtils.getDateFromString(date,dateformat); assertEquals(calendar.get(Calendar.YEAR),2020); assertEquals(calendar.get(Calendar.MONTH),2); assertEquals(calendar.get(Calendar.DATE),12); assertEquals(calendar.get(Calendar.HOUR_OF_DAY),15); assertEquals(calendar.get(Calendar.MINUTE),15); assertEquals(calendar.get(Calendar.SECOND),15); }