/**
* Validation method for VchDt.
*/
public boolean validateVchDtwithinFinyrRange(Date vchdt) {
int count = 0;
if (this.getEntityState() == STATUS_NEW) {
PreparedStatement preparedStatement = null;
ResultSet rs = null;
String sql2 =
"SELECT count(finyr_code) FROM cm_finyr_mst WHERE active_yn='Y' AND ? BETWEEN FINYR_FROM_DT AND FINYR_TO_DT ";
preparedStatement = this.getDBTransaction().createPreparedStatement(sql2, 0);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
java.util.Date d1 = null;
try {
d1 = dateFormat.parse(vchdt.toString());
} catch (ParseException e) {
e.printStackTrace();
}
SimpleDateFormat dateFormat2 = new SimpleDateFormat("dd-MMM-yyyy");
String date = dateFormat2.format(d1);
try {
//preparedStatement.setString(1, this.getCompCode());
preparedStatement.setString(1, date);
rs = preparedStatement.executeQuery();
if (rs.next())
count = rs.getInt(1);
} catch (SQLException sqle) {
sqle.printStackTrace();
} finally {
try {
if (preparedStatement != null && !preparedStatement.isClosed())
preparedStatement.close();
if (rs != null && !rs.isClosed())
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println("Count Value in vch Date validator:" + count);
if (count > 0) {
return true;
} else {
return false;
}
}
return true;
}
* Validation method for VchDt.
*/
public boolean validateVchDtwithinFinyrRange(Date vchdt) {
int count = 0;
if (this.getEntityState() == STATUS_NEW) {
PreparedStatement preparedStatement = null;
ResultSet rs = null;
String sql2 =
"SELECT count(finyr_code) FROM cm_finyr_mst WHERE active_yn='Y' AND ? BETWEEN FINYR_FROM_DT AND FINYR_TO_DT ";
preparedStatement = this.getDBTransaction().createPreparedStatement(sql2, 0);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
java.util.Date d1 = null;
try {
d1 = dateFormat.parse(vchdt.toString());
} catch (ParseException e) {
e.printStackTrace();
}
SimpleDateFormat dateFormat2 = new SimpleDateFormat("dd-MMM-yyyy");
String date = dateFormat2.format(d1);
try {
//preparedStatement.setString(1, this.getCompCode());
preparedStatement.setString(1, date);
rs = preparedStatement.executeQuery();
if (rs.next())
count = rs.getInt(1);
} catch (SQLException sqle) {
sqle.printStackTrace();
} finally {
try {
if (preparedStatement != null && !preparedStatement.isClosed())
preparedStatement.close();
if (rs != null && !rs.isClosed())
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println("Count Value in vch Date validator:" + count);
if (count > 0) {
return true;
} else {
return false;
}
}
return true;
}
Comments
Post a Comment