2 Replies Latest reply: May 15, 2014 7:05 AM by gimbal2 RSS

    compare same date  showing up in two different ranges

    Tshifhiwa

      hi am comparing date with following requirement the value date transction must be within the Active date(>= greater than or equal) and inactive date(<= less than) date range,my problem is date is showing up in two diffirent ranges with the results of that am geting two error message

       

      lets say the date is

      transdate=2014-05-16

      activedate=24/APR/14

      inactivedate=25/APR/14

      s

       

      my code is

       

      try

                              {

                                 String s_ActivDate = getValueFromTable("S", "EXCEPTION_NAME", "EXCEPTION_NAME", s_exceptionName, "EXCEPTION_NAME_DATE_ACTIVE");

                                 String s_InactiveDate = getValueFromTable("S", "EXCEPTION_NAME", "EXCEPTION_NAME", s_exceptionName, "EXCEPTION_NAME_DATE_INACTIVE");  

                      

                         

                                  System.out.println("Systemoutdateafer "+sDate);

                                  System.out.println("Systemouts_InactiveDateafter "+s_InactiveDate);

                                  System.out.println("Systemouts_ActivDateafter "+s_ActivDate);

                                  System.out.println("Systemouts_ActivDateafter "+s_exceptionName);

                         

                         

                                  //if (validate.validateException(s_exceptionName))

                                  if(s_ActivDate != null)

                                  {

                               if(s_InactiveDate != null)

                             {

                               if(!isActive(sDate,s_InactiveDate, s_ActivDate))    

                              {

                              

                          

                              

                                      System.out.println("Systemoutdate "+sDate);

                                      System.out.println("Systemouts_InactiveDate "+s_InactiveDate);

                                      System.out.println("Systemouts_ActivDate "+s_ActivDate);

                                      System.out.println("Systemouts_ActivDate "+s_exceptionName);

       

                                  }

                              }

                                  }

                              } catch (SQLException ex)

                          {

                                   System.out.println("Systemouts_ActivDate "+s_exceptionName);

                                  java.util.logging.Logger.getLogger(ValidateFile.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

                              }

                          }

       

      public boolean isActive(String sValueDate, String sInactive, String sActive)

          {

              Date date_active;

              Date date_inactive;

              System.out.println("Value Date "+sValueDate+" Active "+sActive+" InActive"+sInactive);

              try

              {

          

                  date_active = new SimpleDateFormat("yyyy-MM-dd").parse(sActive);

                  Date dt_valueDate = new SimpleDateFormat("yyyy-MM-dd").parse(sValueDate);

          

                  if(!isBlank(sInactive))

                  {

                      date_inactive = new SimpleDateFormat("yyyy-MM-dd").parse(sInactive);

                      if (dt_valueDate.compareTo(date_inactive) < 0 && dt_valueDate.compareTo(date_active) >= 0)

                      {

                          return true;

                      }

                  }else

                  {

                      if (dt_valueDate.compareTo(date_active) >= 0)

                      {

                          return true;

                      }

                  }

          

              } catch (ParseException ex)

              {

                  java.util.logging.Logger.getLogger(Validate.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

              }catch(NullPointerException npe)

              {

                  return false;

              }

       

              return false;

          }