String minutesStr = "49"; // minutes string to search for in formatted result
int[] dateStylesList = { DateFormat.RELATIVE_FULL, DateFormat.RELATIVE_LONG, DateFormat.RELATIVE_MEDIUM, DateFormat.RELATIVE_SHORT };
for (int i = 0; i < dateStylesList.length; i++) {
int dateStyle = dateStylesList[i];
DateFormat fmtRelDateTime = DateFormat.getDateTimeInstance(dateStyle, DateFormat.SHORT, loc);
DateFormat fmtRelDate = DateFormat.getDateInstance(dateStyle, loc);
DateFormat fmtTime = DateFormat.getTimeInstance(DateFormat.SHORT, loc);
for (int dayOffset = -2; dayOffset <= 2; dayOffset++ ) {
StringBuffer dateTimeStr = new StringBuffer(64);
StringBuffer dateStr = new StringBuffer(64);
StringBuffer timeStr = new StringBuffer(64);
FieldPosition fp = new FieldPosition(DateFormat.MINUTE_FIELD);
cal.setTime(today);
cal.add(Calendar.DATE, dayOffset);
fmtRelDateTime.format(cal, dateTimeStr, fp);
fmtRelDate.format(cal, dateStr, new FieldPosition(0) );
fmtTime.format(cal, timeStr, new FieldPosition(0) );
// check that dateStr is in dateTimeStr
if ( dateTimeStr.toString().indexOf( dateStr.toString() ) < 0 ) {
errln("relative date string not found in datetime format with timeStyle SHORT, dateStyle " +
dateStyle + " for dayOffset " + dayOffset );