Skip to content

Instantly share code, notes, and snippets.

@jthmiranda
Created August 13, 2014 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jthmiranda/54da7d186d5277088d35 to your computer and use it in GitHub Desktop.
Save jthmiranda/54da7d186d5277088d35 to your computer and use it in GitHub Desktop.
metodos con el que podes obtener el nombre de los dias y meses -- by miguelsr
public static String getNumDia(String fecha) {
Calendar c = Calendar.getInstance();
try {
SimpleDateFormat sm = new SimpleDateFormat("dd/MM/yyyy");
c.setTime(sm.parse(fecha));
return String.valueOf(c.get(5));
} catch (ParseException ex) {
GenericsUtils.sendExceptionToLogger("sae.pb", ex);
}
return "";
}
public static String getNomDia(String fecha) {
Calendar c = Calendar.getInstance();
try {
c.setTime(new SimpleDateFormat("dd/MM/yyyy").parse(fecha));
return dias[(c.get(7) - 1)];
} catch (ParseException ex) {
GenericsUtils.sendExceptionToLogger("sae.pb", ex);
}
return "";
}
public static String getNomMes(String fecha) {
Calendar c = Calendar.getInstance();
try {
c.setTime(new SimpleDateFormat("dd/MM/yyyy").parse(fecha));
return meses[c.get(2)];
} catch (ParseException ex) {
GenericsUtils.sendExceptionToLogger("sae.pb", ex);
}
return "";
}
public static String getNumAnyo(String fecha) {
Calendar c = Calendar.getInstance();
try {
c.setTime(new SimpleDateFormat("dd/MM/yyyy").parse(fecha));
return String.valueOf(c.get(1));
} catch (ParseException ex) {
GenericsUtils.sendExceptionToLogger("sae.pb", ex);
}
return "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment