Created
January 16, 2020 21:48
-
-
Save parzibyte/dc8f27f247c7339926355ce6f3002f07 to your computer and use it in GitHub Desktop.
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
class Utiles { | |
public static String obtenerHoraActual(String zonaHoraria) { | |
String formato = "HH:mm:ss"; | |
return Utiles.obtenerFechaConFormato(formato, zonaHoraria); | |
} | |
public static String obtenerFechaActual(String zonaHoraria) { | |
String formato = "yyyy-MM-dd"; | |
return Utiles.obtenerFechaConFormato(formato, zonaHoraria); | |
} | |
@SuppressLint("SimpleDateFormat") | |
public static String obtenerFechaConFormato(String formato, String zonaHoraria) { | |
Calendar calendar = Calendar.getInstance(); | |
Date date = calendar.getTime(); | |
SimpleDateFormat sdf; | |
sdf = new SimpleDateFormat(formato); | |
sdf.setTimeZone(TimeZone.getTimeZone(zonaHoraria)); | |
return sdf.format(date); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment