@Test(dataProvider = "convertToUnixTimestampDP") public void convertToUnixTimestamp(Date date, String expectedUnixTimestamp) { UnixTimestampConverterFunction utcf = new UnixTimestampConverterFunction(); assertEquals(utcf.execute(Collections.singletonList(date)), expectedUnixTimestamp); }
@Override protected Object execute(List<Object> arguments) { return Optional.ofNullable((Date) arguments.get(0)) .map(date -> String.format(Locale.ENGLISH, "%.3f", new BigDecimal(date.getTime()).divide(new BigDecimal(1000)))) .orElse("-1"); }
UnixTimestampConverterFunction extends AbstractFunction { @Override protected Object execute(List<Object> arguments) { return Optional.ofNullable((Date) arguments.get(0)) .map(date -> String.format(Locale.ENGLISH, "%.3f", new BigDecimal(date.getTime()).divide(new BigDecimal(1000)))) .orElse("-1"); } }
UnixTimestampConverterFunction extends AbstractFunction { @Override protected Object execute(List<Object> arguments) { return Optional.ofNullable((Date) arguments.get(0)) .map(date -> String.format(Locale.ENGLISH, "%.3f", new BigDecimal(date.getTime()).divide(new BigDecimal(1000)))) .orElse("-1"); }  }
UnixTimestampConverterFunction extends AbstractFunction { @Override protected Object execute(List<Object> arguments) { return Optional.ofNullable((Date) arguments.get(0)) .map(date -> String.format(Locale.ENGLISH, "%.3f", new BigDecimal(date.getTime()).divide(new BigDecimal(1000)))) .orElse("-1"); }  @Override String name(); @Override int getExpectedNumberOfArguments(); @Override List<Class> getExpectedArgumentTypes(); }
UnixTimestampConverterFunction extends AbstractFunction { @Override protected Object execute(List<Object> arguments) { return Optional.ofNullable((Date) arguments.get(0)) .map(date -> String.format(Locale.ENGLISH, "%.3f", new BigDecimal(date.getTime()).divide(new BigDecimal(1000)))) .orElse("-1"); }  @Override String name(); @Override int getExpectedNumberOfArguments(); @Override List<Class> getExpectedArgumentTypes();  }