public static Calendar getLongFromDateTime(String date, String dateFormat, String time,
      String timeFormat) {
    Calendar cal = Calendar.getInstance();
    Calendar cDate = Calendar.getInstance();
    Calendar cTime = Calendar.getInstance();
    SimpleDateFormat sdfDate = new SimpleDateFormat(dateFormat);
    SimpleDateFormat sdfTime = new SimpleDateFormat(timeFormat);
    try {
      cDate.setTime(sdfDate.parse(date));
      cTime.setTime(sdfTime.parse(time));
    } catch (ParseException e) {
      LogDelegate.e("Date or time parsing error: " + e.getMessage());
    }
    cal.set(Calendar.YEAR, cDate.get(Calendar.YEAR));
    cal.set(Calendar.MONTH, cDate.get(Calendar.MONTH));
    cal.set(Calendar.DAY_OF_MONTH, cDate.get(Calendar.DAY_OF_MONTH));
    cal.set(Calendar.HOUR_OF_DAY, cTime.get(Calendar.HOUR_OF_DAY));
    cal.set(Calendar.MINUTE, cTime.get(Calendar.MINUTE));
    cal.set(Calendar.SECOND, 0);
    return cal;
  }
@Test
  public void getLongFromDateTimeTest() {
    String date = "2020-03-12";
    String dateformat = "yyyy-MM-dd";
    String time = "15:15:15";
    String timeformat = "HH:mm:ss";
    Calendar calendar = DateUtils.getLongFromDateTime(date, dateformat, time, timeformat);
    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), 0);
  }