if (Strings.isEmpty(value))
{
return null;
}
DateTimeFormatter format = getFormat(locale);
if (format == null)
{
throw new IllegalStateException("format must be not null");
}
if (applyTimeZoneDifference)
{
TimeZone zone = getClientTimeZone();
DateTime dateTime = null;
// set time zone for client
format = format.withZone(getTimeZone());
try
{
// parse date retaining the time of the submission
dateTime = format.parseDateTime(value);
}
catch (RuntimeException e)
{
throw new ConversionException(e);
}
// apply the server time zone to the parsed value
if (zone != null)
{
dateTime = dateTime.withZoneRetainFields(DateTimeZone.forTimeZone(zone));
}
return dateTime.toDate();
}
else
{
try
{
DateTime date = format.parseDateTime(value);
return date.toDate();
}
catch (RuntimeException e)
{
throw new ConversionException(e);