@Test public void testToDisplay() { final String rawString = "raw"; final String date = "date"; final String time = "time"; final String displayDate = "displayDate"; final String displayTime = "displayTime"; final String expected = displayDate + ", " + displayTime; final DateTimeValue dateTimeValue = new DateTimeValue(); dateTimeValue.setDate(date); dateTimeValue.setTime(time); doReturn(dateTimeValue).when(converter).fromDMNString(rawString); when(dateValueFormatter.toDisplay(date)).thenReturn(displayDate); when(timeValueFormatter.toDisplay(time)).thenReturn(displayTime); final String actual = converter.toDisplay(rawString); assertEquals(expected, actual); }
public String toDisplay(final String rawValue) { final DateTimeValue value = fromDMNString(rawValue); final String date = dateValueFormatter.toDisplay(value.getDate()); if (value.hasTime()) { return date + ", " + timeValueFormatter.toDisplay(value.getTime()); } else { return date; } }
DateTimeValueConverter { public String toDisplay(final String rawValue) { final DateTimeValue value = fromDMNString(rawValue); final String date = dateValueFormatter.toDisplay(value.getDate()); if (value.hasTime()) { return date + ", " + timeValueFormatter.toDisplay(value.getTime()); } else { return date; } } }
DateTimeValueConverter { public String toDisplay(final String rawValue) { final DateTimeValue value = fromDMNString(rawValue); final String date = dateValueFormatter.toDisplay(value.getDate()); if (value.hasTime()) { return date + ", " + timeValueFormatter.toDisplay(value.getTime()); } else { return date; } } @Inject  DateTimeValueConverter(final DateValueFormatter dateValueFormatter,
                                  final TimeValueFormatter timeValueFormatter); }
DateTimeValueConverter { public String toDisplay(final String rawValue) { final DateTimeValue value = fromDMNString(rawValue); final String date = dateValueFormatter.toDisplay(value.getDate()); if (value.hasTime()) { return date + ", " + timeValueFormatter.toDisplay(value.getTime()); } else { return date; } } @Inject  DateTimeValueConverter(final DateValueFormatter dateValueFormatter,
                                  final TimeValueFormatter timeValueFormatter); String toDMNString(final DateTimeValue value); DateTimeValue fromDMNString(final String dmnString); String toDisplay(final String rawValue); }
DateTimeValueConverter { public String toDisplay(final String rawValue) { final DateTimeValue value = fromDMNString(rawValue); final String date = dateValueFormatter.toDisplay(value.getDate()); if (value.hasTime()) { return date + ", " + timeValueFormatter.toDisplay(value.getTime()); } else { return date; } } @Inject  DateTimeValueConverter(final DateValueFormatter dateValueFormatter,
                                  final TimeValueFormatter timeValueFormatter); String toDMNString(final DateTimeValue value); DateTimeValue fromDMNString(final String dmnString); String toDisplay(final String rawValue);  }