1 Reply Latest reply on Mar 6, 2014 11:46 PM by rp0428

    assign current null value to caurrent date value


      hi how can i assign current  null value to current date,i only what to assign this if the current value coming from database is null otherwise i must use value from database

      public static String getDate(Calendar cal){

              return "" + cal.get(Calendar.DATE) +"/" +

                      (cal.get(Calendar.MONTH)+1) + "/" + cal.get(Calendar.YEAR);


      try {

      s_ActiveDate = getValueFromTable("S", "AD_RPT_QUAL_LINK", "AD_RPT_QUAL_AD_CODE",s_adCode, "AD_RPT_QUAL_ACTIVE_DATE");

      s_InactiveDate = getValueFromTable("S","AD_RPT_QUAL_LINK","AD_RPT_QUAL_AD_CODE",s_adCode,"AD_RPT_QUAL_INACTIVE_DATE");


      System.out.println("+++++++after queryActive************ "+s_ActiveDate );

      System.out.println("+++++++after queryInactive************ "+s_InactiveDate );

      System.out.println("+++++++after queryInactive************ "+s_adCode );



      Date t_date1 = null;

      Date i_date1 = null;

      Date currentdate = null;

      //Date dateBefore = null;

      if(s_ActiveDate != null){

          if(s_InactiveDate != null)


               t_date1 = new SimpleDateFormat("yyyy-MM-dd").parse(s_ActiveDate);

               i_date1 = new SimpleDateFormat("yyyy-MM-dd").parse(s_InactiveDate);




          if(t_date1.compareTo(i_date1) <= 0){

              em.setS_errorMessage("ReportingQualifier-REPORT_QUAL_DATE_INACTIVE", 541,cc);



              if(s_ActiveDate == null) {

                  Calendar cal = Calendar.getInstance();


                        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy",Locale.ENGLISH);



                     // s_ActiveDate.equals(getDate(cal));

                       //test  ==(getDate(cal));

                       //s_ActiveDate == getDate(cal);

                        System.out.println("current dateInsideif: " + (getDate(cal)));


                  if(s_InactiveDate == null){

                      Calendar cal = Calendar.getInstance();


                       String d =  getDate(cal);//intialize your date to any date

                       System.out.println("current dateInsideif: " +d);

                         Date t_date = new SimpleDateFormat("dd/MM/yyyy").parse(d);

                             int n= -30;

                              System.out.println("current dateInsideifformated: " +t_date);

                        dateBefore = new Date(t_date.getTime() - n * 24 * 3600 * 1000 );



                         System.out.println("current dateInsideifformatedsubtracted: " +t_date);






                         System.out.println("Activedatebefore" +s_ActiveDate);

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

                        System.out.println("adcode ++++===="+s_adCode);

                         System.out.println("qualifiee************ "+s_reportingQualifier);



                         System.out.println("INActivedateAfter****" +dateBefore);





                      if(currentdate.compareTo(dateBefore) <= 0 ) {





                               System.out.println("INActivedateAfter****" +dateBefore);









                          } catch (SQLException ex) {

                  try {

                      throw new SQLException(ex);

                  } catch (SQLException ex1) {

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



        • 1. Re: assign current null value to caurrent date value

          So have  you now abandoned the sql forum thread where we have been trying to help you? If so the mark it ANSWERED so you don't waste anyone else's time on it.



          Several of us ask you questions and you never answered them. We also suggested that you first write your query MANUALLY and test it to make sure you get the correct results instead of trying to construct it dynamicaly.


          You never bothered to do that either. If you want help you also need to answer the questions that people ask you.


          Again you have posted code but have NOT posted the session showing the execution of the code and the results that it gives. We told you about this in your other thread.


          You need to SHOW us, not tell us.