### Question:
DateTimeUtils { public static String getBeginningInstant(String timeStamp) { if (timeStamp.endsWith("Z")) { if (timeStamp.indexOf("T") == -1) { StringBuffer buf = new StringBuffer(timeStamp); int lastZ = buf.lastIndexOf("Z"); buf.insert(lastZ, "T"); timeStamp = buf.toString(); } } Pattern pattern = Pattern.compile(".*[+-]\\d{2}:\\d{2}"); Matcher matcher = pattern.matcher(timeStamp); if (matcher.matches()) { if (timeStamp.indexOf("T") == -1) { StringBuffer buf = new StringBuffer(timeStamp); int lastColon = buf.lastIndexOf(":"); buf.insert(lastColon - 3, "T"); timeStamp = buf.toString(); } } DateTimeFormatter formatter = ISODateTimeFormat .dateOptionalTimeParser(); DateTime dateTime = null; try { dateTime = formatter.parseDateTime(timeStamp); } catch (Exception e) { System.out.println("DateTimeUtils ERROR: " + e.getMessage()); } return dateTime.toString(); }  static String getBeginningInstant(String timeStamp);  }### Answer:
@Test public void getBeginningInstantForDate() { String date = "2013-04-25Z"; String beginVal = DateTimeUtils.getBeginningInstant(date); DateTime dateTime = DateTime.parse(beginVal); DateTime beginDay = DateTime.parse("2013-04-25T00:00.00Z"); assertEquals("Expected time instants to be equal.", 0, dateTime.compareTo(beginDay)); }