@Test public void testWildCards() { byte[] source = new byte[] { (byte) 0x07, (byte) 0xDF, 6, (byte) 0xFF, (byte) 0xFF }; final CosemDateConverter converter = new CosemDateConverter(); CosemDate date = converter.convert(source, converter.getBType(), null); assertThat(date.getYear()).isEqualTo(2015); assertThat(date.getMonth()).isEqualTo(6); assertThat(date.getDayOfMonth()).isEqualTo(0xFF); assertThat(date.getDayOfWeek()).isEqualTo(0xFF); source = new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFE, (byte) 0xFD, (byte) 0xFF }; date = converter.convert(source, converter.getBType(), null); assertThat(date.getYear()).isEqualTo(0xFFFF); assertThat(date.getMonth()).isEqualTo(0xFE); assertThat(date.getDayOfMonth()).isEqualTo(0xFD); assertThat(date.getDayOfWeek()).isEqualTo(0xFF); source = new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFE, 21, 3 }; date = converter.convert(source, converter.getBType(), null); assertThat(date.getYear()).isEqualTo(0xFFFF); assertThat(date.getMonth()).isEqualTo(0xFE); assertThat(date.getDayOfMonth()).isEqualTo(21); assertThat(date.getDayOfWeek()).isEqualTo(3); }
@Override public CosemDate convert(final byte[] source, final Type<? extends CosemDate> destinationType, final MappingContext context) { final ByteBuffer bb = ByteBuffer.wrap(source); final int year = bb.getShort() & 0xFFFF; final int month = bb.get() & 0xFF; final int day = bb.get() & 0xFF; final int weekDay = bb.get() & 0xFF; return new CosemDate(year, month, day, weekDay); }
CosemDateConverter extends CustomConverter<byte[], CosemDate> { @Override public CosemDate convert(final byte[] source, final Type<? extends CosemDate> destinationType, final MappingContext context) { final ByteBuffer bb = ByteBuffer.wrap(source); final int year = bb.getShort() & 0xFFFF; final int month = bb.get() & 0xFF; final int day = bb.get() & 0xFF; final int weekDay = bb.get() & 0xFF; return new CosemDate(year, month, day, weekDay); } }
CosemDateConverter extends CustomConverter<byte[], CosemDate> { @Override public CosemDate convert(final byte[] source, final Type<? extends CosemDate> destinationType, final MappingContext context) { final ByteBuffer bb = ByteBuffer.wrap(source); final int year = bb.getShort() & 0xFFFF; final int month = bb.get() & 0xFF; final int day = bb.get() & 0xFF; final int weekDay = bb.get() & 0xFF; return new CosemDate(year, month, day, weekDay); }  }
CosemDateConverter extends CustomConverter<byte[], CosemDate> { @Override public CosemDate convert(final byte[] source, final Type<? extends CosemDate> destinationType, final MappingContext context) { final ByteBuffer bb = ByteBuffer.wrap(source); final int year = bb.getShort() & 0xFFFF; final int month = bb.get() & 0xFF; final int day = bb.get() & 0xFF; final int weekDay = bb.get() & 0xFF; return new CosemDate(year, month, day, weekDay); }  @Override CosemDate convert(final byte[] source, final Type<? extends CosemDate> destinationType,
            final MappingContext context); }
CosemDateConverter extends CustomConverter<byte[], CosemDate> { @Override public CosemDate convert(final byte[] source, final Type<? extends CosemDate> destinationType, final MappingContext context) { final ByteBuffer bb = ByteBuffer.wrap(source); final int year = bb.getShort() & 0xFFFF; final int month = bb.get() & 0xFF; final int day = bb.get() & 0xFF; final int weekDay = bb.get() & 0xFF; return new CosemDate(year, month, day, weekDay); }  @Override CosemDate convert(final byte[] source, final Type<? extends CosemDate> destinationType,
            final MappingContext context);  }