try this...
Code:System.out.println("File Supplied. Getting date from the file."); //SPRINTPCS0.I80140.08210153481 // Variable declars // int intFileMonth; int intFileDay; int intCurrentMonth; int intCurrentDay; int intCurrentYear; String strDateRunningFor = new String(); String strYear = new String(); String strMonth = new String(); String strDay = new String(); Date currenttime = new Date(); // get todays date // formats for date SimpleDateFormat formatterMonth = new SimpleDateFormat("MM"); SimpleDateFormat formatterDay = new SimpleDateFormat("dd"); SimpleDateFormat formatterYear = new SimpleDateFormat("yyyy"); strDateRunningFor = args[1]; // get filename information strMonth = strDateRunningFor.substring(18,20) // get string for month strDay = strDateRunningFor.substring(20,22) // get string for day intFileMonth = Integer.parseInt(strMonth); // get month from filename intFileDay = Integer.parseInt(strDay); // get day from filename // temp dump out of month and day System.out.println("intFileMonth " + intFileMonth + " intFileDaye " + intFileDay); // parse todays date to get month, day, and year intCurrentMonth = Integer.parseInt(formatterMonth.format(currenttime)); intCurrentDay = Integer.parseInt(formatterDay.format(currenttime)); intCurrentYear = Integer.parseInt(formatterYear.format(currenttime)); // compute the year for the filename if(intFileMonth < intCurrentMonth || (intFileMonth==intCurrentMonth && intFileDay<=intCurrentDay)) { //Current Year so just set year string to current year strYear = intCurrentYear; } else { //Previous Year, so we need to just subtract a year off the current year strYear = (intCurrentYear-1); } //System.out.println(strYear + "" + strMonth + "" + strDay); strDateRunningFor = strYear + "" + strMonth + "" + strDay;




Reply With Quote