@Test public void testGetWhenThrowsNullPointerException() throws Throwable { DailyTaskAdaptor dailyTaskAdaptor = new DailyTaskAdaptor(); try { dailyTaskAdaptor.getWhen(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.core.Configuration.get(String)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(dailyTaskAdaptor.getConfiguration(), "dailyTaskAdaptor.getConfiguration()"); } }
public Date getWhen() { String s = cfg.get ("start")+":00:00"; int hh = Integer.parseInt(s.substring (0, 2)); int mm = Integer.parseInt(s.substring (3, 5)); int ss = Integer.parseInt(s.substring (6, 8)); Date now = new Date(); Calendar cal = new GregorianCalendar(); cal.setTime (now); cal.set (Calendar.HOUR_OF_DAY, hh); cal.set (Calendar.MINUTE, mm); cal.set (Calendar.SECOND, ss); Date when = cal.getTime(); if (when.before(now)) when = new Date(when.getTime() + 24*60*60*1000); return when; }
DailyTaskAdaptor extends QBeanSupport implements Runnable { public Date getWhen() { String s = cfg.get ("start")+":00:00"; int hh = Integer.parseInt(s.substring (0, 2)); int mm = Integer.parseInt(s.substring (3, 5)); int ss = Integer.parseInt(s.substring (6, 8)); Date now = new Date(); Calendar cal = new GregorianCalendar(); cal.setTime (now); cal.set (Calendar.HOUR_OF_DAY, hh); cal.set (Calendar.MINUTE, mm); cal.set (Calendar.SECOND, ss); Date when = cal.getTime(); if (when.before(now)) when = new Date(when.getTime() + 24*60*60*1000); return when; } }
DailyTaskAdaptor extends QBeanSupport implements Runnable { public Date getWhen() { String s = cfg.get ("start")+":00:00"; int hh = Integer.parseInt(s.substring (0, 2)); int mm = Integer.parseInt(s.substring (3, 5)); int ss = Integer.parseInt(s.substring (6, 8)); Date now = new Date(); Calendar cal = new GregorianCalendar(); cal.setTime (now); cal.set (Calendar.HOUR_OF_DAY, hh); cal.set (Calendar.MINUTE, mm); cal.set (Calendar.SECOND, ss); Date when = cal.getTime(); if (when.before(now)) when = new Date(when.getTime() + 24*60*60*1000); return when; } DailyTaskAdaptor(); }
DailyTaskAdaptor extends QBeanSupport implements Runnable { public Date getWhen() { String s = cfg.get ("start")+":00:00"; int hh = Integer.parseInt(s.substring (0, 2)); int mm = Integer.parseInt(s.substring (3, 5)); int ss = Integer.parseInt(s.substring (6, 8)); Date now = new Date(); Calendar cal = new GregorianCalendar(); cal.setTime (now); cal.set (Calendar.HOUR_OF_DAY, hh); cal.set (Calendar.MINUTE, mm); cal.set (Calendar.SECOND, ss); Date when = cal.getTime(); if (when.before(now)) when = new Date(when.getTime() + 24*60*60*1000); return when; } DailyTaskAdaptor(); void run(); Date getWhen(); }
DailyTaskAdaptor extends QBeanSupport implements Runnable { public Date getWhen() { String s = cfg.get ("start")+":00:00"; int hh = Integer.parseInt(s.substring (0, 2)); int mm = Integer.parseInt(s.substring (3, 5)); int ss = Integer.parseInt(s.substring (6, 8)); Date now = new Date(); Calendar cal = new GregorianCalendar(); cal.setTime (now); cal.set (Calendar.HOUR_OF_DAY, hh); cal.set (Calendar.MINUTE, mm); cal.set (Calendar.SECOND, ss); Date when = cal.getTime(); if (when.before(now)) when = new Date(when.getTime() + 24*60*60*1000); return when; } DailyTaskAdaptor(); void run(); Date getWhen();  }