This file contains hidden or 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
import java.text.DateFormat; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
import java.util.TimeZone; | |
public class TimeZoneExample { | |
public static void main(String[] args) { | |
DateFormat inFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
inFormat.setTimeZone(TimeZone.getTimeZone("America/Guatemala")); | |
Date purchaseDate = new Date(); | |
System.out.println("Fecha/Hora Original"); | |
System.out.println(inFormat.format(purchaseDate)); | |
DateFormat outFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
outFormat.setTimeZone(TimeZone.getTimeZone("Europe/Spain")); | |
System.out.println("Misma Fecha/Hora en España"); | |
System.out.println(outFormat.format(purchaseDate)); | |
} | |
} |
This file contains hidden or 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
Fecha/Hora Original | |
2013-04-19 22:54:51 | |
Misma Fecha/Hora en España | |
2013-04-20 04:54:51 |
No hay comentarios :
Publicar un comentario