Created
August 13, 2014 21:32
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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