hola quisiera ver si me pudieran ayudar con una clase de java tengo esta clase donde calcula el primer dia de la semana de x mes
yo mando a imprimir esto
<pre lang='java'> System.out.println("gggg"+ himfg.clases.cFunciones.primerosDiasXmes(2012, 5));
año dia(jueves)
public static HashMap<Integer, Integer> primerosDiasXmes(int year, int dia) throws ClassNotFoundException, SQLException {
HashMap<Integer, Integer> hmdias = new HashMap<Integer, Integer>();
String DATE_FORMAT = "yyyyMMdd";
SimpleDateFormat sdf =
new SimpleDateFormat(DATE_FORMAT);
Calendar c1 = Calendar.getInstance(); // today
for (int m = Calendar.JANUARY; m <= Calendar.DECEMBER; m++) {
Calendar cal = new GregorianCalendar(year, m, 1);
cal.set(Calendar.WEEK_OF_YEAR, cal.getActualMinimum(Calendar.WEEK_OF_YEAR));
int diff = dia - cal.get(Calendar.DAY_OF_WEEK);
//System.out.println("n"+diff);
if (diff < 0) {
diff += 7;
}
cal.add(Calendar.DAY_OF_MONTH, diff);
System.out.println("**** '' " + sdf.format(cal.getTime())); //in (20110830,1521021)
//System.out.println(sdf.format(c1.getTime()));
hmdias.put(Integer.parseInt(sdf.format(cal.getTime())), Integer.parseInt(sdf.format(cal.getTime())));
}
return hmdias;
}
y al final me imprime 20120202=20120202, 20120607=20120607, 20120405=20120405, 20120301=20120301, 20120802=20120802, 20120906=20120906, 20121101=20121101, 20120705=20120705, 20120105=20120105, 20121206=20121206, 20121004=20121004, 20120503=20120503}
ahora quiero obtener el primer dia jueves y el tercer jueves del mes