static public Timestamp nextBusinessDay(Timestamp day) throws SQLException {
  if (day == null)   day=new Timestamp(System.currentTimeMillis());
  GregorianCalendar cal=new GregorianCalendar();
  cal.setTime(day);
  cal.set(Calendar.HOUR_OF_DAY,0);
  cal.set(Calendar.MINUTE,0);
  cal.set(Calendar.SECOND,0);
  cal.set(Calendar.MILLISECOND,0);
  boolean isHoliday=true;
  do {
    int dow=cal.get(Calendar.DAY_OF_WEEK);
    if (dow == Calendar.SATURDAY)     cal.add(Calendar.DAY_OF_YEAR,2);
 else     if (dow == Calendar.SUNDAY)     cal.add(Calendar.DAY_OF_YEAR,1);
    java.util.Date temp=cal.getTime();
    String sql="SELECT Date1 FROM C_NonBusinessDay WHERE IsActive ='Y' AND Date1=?";
    PreparedStatement pstmt=Adempiere.prepareStatement(sql);
    pstmt.setTimestamp(1,new Timestamp(temp.getTime()));
    ResultSet rs=pstmt.executeQuery();
    if (rs.next()) {
      cal=new GregorianCalendar();
      cal.setTime(temp);
      cal.add(Calendar.DAY_OF_YEAR,1);
    }
 else     isHoliday=false;
    rs.close();
    pstmt.close();
  }
 while (isHoliday);
  return new Timestamp(cal.getTimeInMillis());
}

static public Timestamp nextBusinessDay ( Timestamp day ) throws SQLException { if ( day == null ) day = new Timestamp ( System . currentTimeMillis ( ) ) ; GregorianCalendar cal = new GregorianCalendar ( ) ; cal . setTime ( day ) ; cal . set ( Calendar . HOUR_OF_DAY , 0 ) ; cal . set ( Calendar . MINUTE , 0 ) ; cal . set ( Calendar . SECOND , 0 ) ; cal . set ( Calendar . MILLISECOND , 0 ) ; boolean isHoliday = true ; do { int dow = cal . get ( Calendar . DAY_OF_WEEK ) ; if ( dow == Calendar . SATURDAY ) cal . add ( Calendar . DAY_OF_YEAR , 2 ) ; else if ( dow == Calendar . SUNDAY ) cal . add ( Calendar . DAY_OF_YEAR , 1 ) ; java . util . Date temp = cal . getTime ( ) ; String sql = "SELECT Date1 FROM C_NonBusinessDay WHERE IsActive ='Y' AND Date1=?" ; PreparedStatement pstmt = Adempiere . prepareStatement ( sql ) ; pstmt . setTimestamp ( 1 , new Timestamp ( temp . getTime ( ) ) ) ; ResultSet rs = pstmt . executeQuery ( ) ; if ( rs . next ( ) ) { cal = new GregorianCalendar ( ) ; cal . setTime ( temp ) ; cal . add ( Calendar . DAY_OF_YEAR , 1 ) ; } else isHoliday = false ; rs . close ( ) ; pstmt . close ( ) ; } while ( isHoliday ) ; return new Timestamp ( cal . getTimeInMillis ( ) ) ; }
next business day . ( only sa / su - > mo )
