Note: Use below code as it is and cheers :)
private static final String currentWeekNumber="SELECT to_number(TO_CHAR(to_date(sysdate),'WW') , '99') currentWeek FROM Dual";//make change for current week
public static int getCurrentWeekNumber(Connection connect) throws Exception{
PreparedStatement pStat = null;
ResultSet rs = null;
String currentWeek=null;
try {
if(connect!=null){
pStat = connect.prepareStatement(currentWeekNumber);
rs = pStat.executeQuery();
if(rs.next()){
currentWeek = rs.getString("currentWeek");
}
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
finally{
if(pStat!=null){
pStat.close();
pStat=null;
}
if(rs!=null){
rs.close();
rs=null;
}
}
if(currentWeek!=null)
return Integer.parseInt(currentWeek);
else{
return 0;
}
}
private static final String currentWeekNumber="SELECT to_number(TO_CHAR(to_date(sysdate),'WW') , '99') currentWeek FROM Dual";//make change for current week
public static int getCurrentWeekNumber(Connection connect) throws Exception{
PreparedStatement pStat = null;
ResultSet rs = null;
String currentWeek=null;
try {
if(connect!=null){
pStat = connect.prepareStatement(currentWeekNumber);
rs = pStat.executeQuery();
if(rs.next()){
currentWeek = rs.getString("currentWeek");
}
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
finally{
if(pStat!=null){
pStat.close();
pStat=null;
}
if(rs!=null){
rs.close();
rs=null;
}
}
if(currentWeek!=null)
return Integer.parseInt(currentWeek);
else{
return 0;
}
}