{
throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE);
}
final Type type1 = parameters.getType(0);
final Object value1 = parameters.getValue(0);
final TypeRegistry typeRegistry = context.getTypeRegistry();
if (parameterCount == 1)
{
final String result = typeRegistry.convertToText(type1, value1);
if(result == null)
{
throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
}
return new TypeValuePair(TextType.TYPE, result);
}
try
{
final Type type2 = parameters.getType(1);
final Object value2 = parameters.getValue(1);
final String formatString = typeRegistry.convertToText(type2, value2);
final Locale locale = context.getLocalizationContext().getLocale();
if (value1 instanceof Date)
{
final DateFormat dateFormat = new SimpleDateFormat
(formatString, new DateFormatSymbols(locale));
return new TypeValuePair(TextType.TYPE, dateFormat.format(value1));
}
if (value1 instanceof Number)
{
final NumberFormat dateFormat = new DecimalFormat
(formatString, new DecimalFormatSymbols(locale));
return new TypeValuePair(TextType.TYPE, dateFormat.format(value1));
}
try
{
final Date date = typeRegistry.convertToDate(type2, value2);
final DateFormat dateFormat = new SimpleDateFormat
(formatString, new DateFormatSymbols(locale));
return new TypeValuePair(TextType.TYPE, dateFormat.format(date));
}
catch (EvaluationException ev)
{
// ignore
}
try
{
final Number date = typeRegistry.convertToNumber(type2, value2);
final NumberFormat dateFormat = new DecimalFormat
(formatString, new DecimalFormatSymbols(locale));
return new TypeValuePair(TextType.TYPE, dateFormat.format(date));
}
catch (EvaluationException ev)