@Test public void convertDateTime() throws ParseException { AttributeMetaData attr = new DefaultAttributeMetaData("attr").setDataType(MolgenisFieldTypes.DATETIME); assertEquals( DataConverter.convert("2015-05-22T11:12:13+0500", attr), MolgenisDateFormat.getDateTimeFormat().parse("2015-05-22T11:12:13+0500")); }
public static boolean canConvert(Object source, Class<?> targetType) { try { convert(source, targetType); return true; } catch (Exception e) { return false; } }
@Test public void convert() { assertEquals(DataConverter.convert("test", String.class), "test"); assertEquals(DataConverter.convert(5L, Number.class).longValue(), 5L); }