private static final String nuberOfWeek="SELECT ROUND((TO_DATE(LAST_DAY(ADD_MONTHS(sysdate,12 - TO_NUMBER(TO_CHAR(SYSDATE,'MM')))))-TO_DATE((TRUNC(TO_DATE(SYSDATE),'YEAR'))))/7) numberOfWeek FROM DUAL";
public static String getNumberOfWeekInCurrentYear(Connection connect) throws Exception{
PreparedStatement pStat = null;
ResultSet rs = null;
String numberOfWeek=null;
try {
if(connect!=null){
pStat = connect.prepareStatement(nuberOfWeek);
rs = pStat.executeQuery();
if(rs.next()){
numberOfWeek = rs.getString("numberOfWeek");
}
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
finally{
if(pStat!=null){
pStat.close();
pStat=null;
}
if(rs!=null){
rs.close();
rs=null;
}
}
return numberOfWeek;
}
public static String getNumberOfWeekInCurrentYear(Connection connect) throws Exception{
PreparedStatement pStat = null;
ResultSet rs = null;
String numberOfWeek=null;
try {
if(connect!=null){
pStat = connect.prepareStatement(nuberOfWeek);
rs = pStat.executeQuery();
if(rs.next()){
numberOfWeek = rs.getString("numberOfWeek");
}
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
finally{
if(pStat!=null){
pStat.close();
pStat=null;
}
if(rs!=null){
rs.close();
rs=null;
}
}
return numberOfWeek;
}