Java date and time zone Java
If not obtained the correct time with Java, you may not have been taken into account the setting of the zone.
If that were the case, use the following code:
-Gets the date, time and format for a given zone-
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java . util.Date;
java.util.TimeZone import;
/ **
* * @ author Ing.Oscar
Hurtado
* / public class
Main {/ ** * @ param args
the command
line arguments * /
public static void main (String [] args) {
/ / TODO code application logic here Main
orq = new Main ();
dte = orq.getDateTime String ();
System.out.println (DTE);}
GetDateTime public String () {DateFormat dateFormat =
new SimpleDateFormat ("yyyy / MM / dd HH: mm: ss");
/ / DateFormat dateFormat = new SimpleDateFormat ("HH: mm: ss");
/ / To see that IDS are available, uncomment the following
/ *
String [] avail = TimeZone.getAvailableIDs ();
for (int c = 0; c < avail.length; c++) {
System.out.println (avail [c]);}
* /
/ / it sets the ID for the area, in this case to 'La Paz Bolivia'
TimeZone.getTimeZone TimeZone est = ("America / La_Paz");
dateFormat.setTimeZone (est);
date Date = new Date ();
dateFormat.format return (date);
}}