mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
Avoid NPE; just noop
This commit is contained in:
@ -94,6 +94,12 @@ public class DateTimeDisplayValueBehavior implements FieldDisplayBehavior<DateTi
|
||||
try
|
||||
{
|
||||
Instant instant = record.getValueInstant(field.getName());
|
||||
|
||||
if(instant == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ZonedDateTime zonedDateTime = instant.atZone(ZoneId.of(defaultZoneId));
|
||||
record.setDisplayValue(field.getName(), QValueFormatter.formatDateTimeWithZone(zonedDateTime));
|
||||
}
|
||||
@ -116,6 +122,11 @@ public class DateTimeDisplayValueBehavior implements FieldDisplayBehavior<DateTi
|
||||
try
|
||||
{
|
||||
Instant instant = record.getValueInstant(field.getName());
|
||||
if(instant == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String zoneString = record.getValueString(zoneIdFromFieldName);
|
||||
|
||||
ZoneId zoneId = null;
|
||||
|
@ -101,6 +101,7 @@ class DateTimeDisplayValueBehaviorTest extends BaseTest
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@ -124,6 +125,25 @@ class DateTimeDisplayValueBehaviorTest extends BaseTest
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testNullValue()
|
||||
{
|
||||
QInstance qInstance = QContext.getQInstance();
|
||||
QTableMetaData table = qInstance.getTable(TestUtils.TABLE_NAME_PERSON_MEMORY);
|
||||
|
||||
table.withField(new QFieldMetaData("timeZone", QFieldType.STRING));
|
||||
table.getField("createDate").withBehavior(new DateTimeDisplayValueBehavior().withZoneIdFromFieldName("timeZone"));
|
||||
|
||||
QRecord record = new QRecord().withValue("createDate", null).withValue("timeZone", "UTC");
|
||||
ValueBehaviorApplier.applyFieldBehaviors(ValueBehaviorApplier.Action.FORMATTING, qInstance, table, List.of(record), null);
|
||||
assertNull(record.getDisplayValue("createDate"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
Reference in New Issue
Block a user