public String getMartusAnswerStringFromQuestion( IAnswerData answer, QuestionDef question, final int dataType) throws Exception { String answerAsString = answer.getDisplayText(); if (dataType == Constants.DATATYPE_DATE) { answerAsString = formatDateToMartusDateFormat(answerAsString); } else if (shouldTreatSingleItemChoiceListAsBooleanField(dataType, question) && answerAsString.isEmpty()) { answerAsString = FieldSpec.FALSESTRING; } else if (dataType == Constants.DATATYPE_CHOICE) { List<SelectChoice> list = question.getChoices(); for (int i = 0; i < list.size(); ++i) { SelectChoice choice = list.get(i); if (choice.getValue().equals(answerAsString)) { answerAsString = choice.getLabelInnerText(); break; } } } return answerAsString; }