Example usage for java.util TimeZone getTimeZone

List of usage examples for java.util TimeZone getTimeZone

Introduction

In this page you can find the example usage for java.util TimeZone getTimeZone.

Prototype

public static TimeZone getTimeZone(ZoneId zoneId) 

Source Link

Document

Gets the TimeZone for the given zoneId .

Usage

From source file:com.prodigious.festivities.api.app.Application.java

public static void main(String[] args) {
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    SpringApplication springApplication = new SpringApplication(Application.class);
    springApplication.addListeners(new ApplicationPidFileWriter());
    springApplication.run(args);//w  w  w .  ja v  a2  s.  c  o  m
}

From source file:com.qpark.eip.core.model.analysis.config.ModelAnalysisPersistence.java

/**
 * Run the spring boot application./*w  w  w  .  j av a2 s  .  co m*/
 *
 * @param args
 *            the arguments.
 */
public static void main(final String[] args) {
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    System.setProperty("file.encoding", "UTF-8");
    SpringApplication.run(ModelAnalysisPersistence.class, args);
}

From source file:gr.cti.android.experimentation.Application.java

public static void main(String[] args) throws Exception {
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    final ConfigurableApplicationContext ctx = SpringApplication.run(Application.class, args);
    for (String name : ctx.getBeanDefinitionNames()) {
        LOGGER.info(name);/*from  w w  w. j a  v a2s . c o  m*/
    }
}

From source file:com.devnexus.ting.DevNexusApplication.java

public static void main(String[] args) throws Exception {
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    final SpringApplication application = new SpringApplication(DevNexusApplication.class);
    application.addInitializers(new DefaultApplicationContextInitializer());
    application.run(args);/*from   w w w  .j  av a2 s  .  c  o m*/
}

From source file:es.emergya.Main.java

/**
 * Starts the app./*  w  w w  .  j  a v  a2 s .  co  m*/
 * 
 * @param args
 */
public static void main(final String[] args) {
    try {
        Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {

            @Override
            public void uncaughtException(final Thread t, final Throwable e) {
                if (LOG.isTraceEnabled()) {
                    LOG.trace("Excepcion descontrolada en " + t.toString(), e);
                } else {
                    LOG.error("Excepcion descontrolada en " + t.toString() + " :: " + e.toString(), e);
                }
            }
        });
    } catch (Throwable t) {
        LOG.error(t, t);
    }

    try {
        TimeZone.setDefault(TimeZone.getTimeZone("Europe/Madrid")); //$NON-NLS-1$
        new Initializer().run();
    } catch (Throwable t) {
        LOG.error("Fallo el SwingUtilities.invokeLater", t);
    }
}

From source file:Tester2.java

public static void main(String[] args) {
    try {//from   w w  w  . j a va2s  . c o m
        String line7 = "1 25544U 98067A   16003.88353887  .00008341  00000-0  12778-3 0  9994";
        String line8 = "2 25544  51.6424 162.4509 0008302 358.1918 164.3460 15.55244436979265";

        double latitude = 36.211389;
        double longitude = -81.668611;
        double altitude = 1016;

        // configure Orekit
        AutoconfigurationCustom.configureOrekit();

        //SUNLocation
        CelestialBody testSun = CelestialBodyFactory.getSun();
        CelestialBody testEarth = CelestialBodyFactory.getEarth();

        // Get UTC time
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy,MM,dd,HH,mm,ss");
        sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
        String[] utcTime = sdf.format(new Date()).split(",");

        // Gets times and date
        double futureDayProp = 3; // duration in 24-hour day 
        //AbsoluteDate currentDate = new AbsoluteDate(2016, 1, 1, 23, 50, 0.000, TimeScalesFactory.getUTC());
        AbsoluteDate currentDate = new AbsoluteDate(Integer.parseInt(utcTime[0]), Integer.parseInt(utcTime[1]),
                Integer.parseInt(utcTime[2]), Integer.parseInt(utcTime[3]), Integer.parseInt(utcTime[4]),
                Integer.parseInt(utcTime[5]), TimeScalesFactory.getUTC());

        Tester2 awesome = new Tester2(line7, line8, testSun, testEarth, latitude, longitude, altitude,
                currentDate.shiftedBy(futureDayProp * 24 * 3600));//targetDate.shiftedBy(3*24*3600));
        awesome.QuickCheck();

        System.out.println("done");

        // Propagate from the initial date to the first raising or for the fixed duration
        ////////////////SpacecraftState finalState = TLEProp.propagate(targetDate);

        ///////////////////System.out.println(" Final state : " + finalState.getDate().durationFrom(targetDate));

    } catch (OrekitException oe) {
        System.err.println(oe.getMessage());
    }
}

From source file:isi.pasco2.Main.java

public static void main(String[] args) {
    CommandLineParser parser = new PosixParser();

    Options options = new Options();
    Option undelete = new Option("d", "Undelete activity records");
    options.addOption(undelete);//from  www  . j av  a 2  s .  co m
    Option disableAllocation = new Option("M", "Disable allocation detection");
    options.addOption(disableAllocation);
    Option fieldDelimeter = OptionBuilder.withArgName("field-delimeter").hasArg()
            .withDescription("Field Delimeter (TAB by default)").create("t");
    options.addOption(fieldDelimeter);

    Option timeFormat = OptionBuilder.withArgName("time-format").hasArg()
            .withDescription("xsd or standard (pasco1 compatible)").create("f");
    options.addOption(timeFormat);

    Option fileTypeOption = OptionBuilder.withArgName("file-type").hasArg()
            .withDescription("The type of file: cache or history").create("T");

    options.addOption(fileTypeOption);

    try {
        CommandLine line = parser.parse(options, args);
        boolean undeleteMethod = false;
        String delimeter = null;
        String format = null;
        String fileType = null;
        boolean disableAllocationTest = false;

        if (line.hasOption("d")) {
            undeleteMethod = true;
        }

        if (line.hasOption('t')) {
            delimeter = line.getOptionValue('t');
        }

        if (line.hasOption('M')) {
            disableAllocationTest = true;
        }

        if (line.hasOption('T')) {
            fileType = line.getOptionValue('T');
        }

        if (line.hasOption('f')) {
            format = line.getOptionValue('f');
        }

        if (line.getArgs().length != 1) {
            System.err.println("No file specified.");
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("pasco2", options);
            System.exit(1);
        }
        String fileName = line.getArgs()[0];

        try {
            IndexFile fr = new FastReadIndexFile(fileName, "r");

            CountingCacheHandler handler = null;

            if (fileType == null) {
                handler = new CountingCacheHandler();
            }
            if (fileType == null) {
                handler = new CountingCacheHandler();
            } else if (fileType.equals("cache")) {
                handler = new CountingCacheHandler();
            } else if (fileType.equals("history")) {
                handler = new Pasco2HistoryHandler();
            }

            if (format != null) {
                if (format.equals("pasco")) {
                    DateFormat regularDateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS");
                    handler.setDateFormat(regularDateFormat);
                    TimeZone tz = TimeZone.getTimeZone("Australia/Brisbane");
                    regularDateFormat.setTimeZone(tz);

                } else if (format.equals("standard")) {
                    DateFormat xsdDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
                    handler.setDateFormat(xsdDateFormat);
                    xsdDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
                } else {
                    System.err.println("Format not supported.");
                    HelpFormatter formatter = new HelpFormatter();
                    formatter.printHelp("pasco2", options);
                    System.exit(1);
                }
            }

            if (delimeter != null) {
                handler.setDelimeter(delimeter);
            }

            IEIndexFileParser logparser = null;
            if (fileType == null) {
                System.err.println("Using cache file parser.");
                logparser = new IECacheFileParser(fileName, fr, handler);
            } else if (fileType.equals("cache")) {
                logparser = new IECacheFileParser(fileName, fr, handler);
            } else if (fileType.equals("history")) {
                logparser = new IEHistoryFileParser(fileName, fr, handler);
            } else {
                System.err.println("Unsupported file type.");
                HelpFormatter formatter = new HelpFormatter();
                formatter.printHelp("pasco2", options);
                System.exit(1);
            }
            if (disableAllocationTest) {
                logparser.setDisableAllocationTest(true);
            }
            logparser.parseFile();

        } catch (Exception ex) {
            System.err.println(ex.getMessage());
            ex.printStackTrace();
        }

    } catch (ParseException exp) {
        System.out.println("Unexpected exception:" + exp.getMessage());
    }
}

From source file:calendarevent.CalendarEvent.java

/**
 * @param args the command line arguments
 *//*  w  ww  .j  a  va2 s.c o m*/
public static void main(String[] args) {
    // TODO code application logic here

    /*       
                
        This has to be replaced with the json data coming from the getJsonData() method
        Expecting the Json will be in the format from the above methid.
                
    */
    String jsonString = "{\n" + " \"kind\": \"calendar#events\",\n"
            + " \"etag\": \"\\\"2DaeHpkENZGECFHdcr5l8tYxjD4/QElT1PHkP9d3G5VSndpdEMlSzKE\\\"\",\n"
            + " \"summary\": \"PushEvents\",\n" + " \"description\": \"Hackathon\",\n"
            + " \"updated\": \"2014-03-29T22:35:18.495Z\",\n" + " \"timeZone\": \"Asia/Calcutta\",\n"
            + " \"accessRole\": \"reader\",\n" + " \"items\": [\n" + "  {\n"
            + "   \"kind\": \"calendar#event\",\n"
            + "   \"etag\": \"\\\"2DaeHpkENZGECFHdcr5l8tYxjD4/MTM5NjEyNTQwNzcxMTAwMA\\\"\",\n"
            + "   \"id\": \"q28lprjb8ad3m17955lf1p9d48\",\n" + "   \"status\": \"confirmed\",\n"
            + "   \"htmlLink\": \"https://www.google.com/calendar/event?eid=cTI4bHByamI4YWQzbTE3OTU1bGYxcDlkNDggM3RvcjdvamZxaWhlamNqNjduOWw0dDhnMmNAZw\",\n"
            + "   \"created\": \"2014-03-29T20:36:47.000Z\",\n"
            + "   \"updated\": \"2014-03-29T20:36:47.711Z\",\n" + "   \"summary\": \"Test API\",\n"
            + "   \"creator\": {\n" + "    \"email\": \"vrohitrao@gmail.com\",\n"
            + "    \"displayName\": \"Rohith Vallu\"\n" + "   },\n" + "   \"organizer\": {\n"
            + "    \"email\": \"3tor7ojfqihejcj67n9l4t8g2c@group.calendar.google.com\",\n"
            + "    \"displayName\": \"PushEvents\",\n" + "    \"self\": true\n" + "   },\n"
            + "   \"start\": {\n" + "    \"dateTime\": \"2014-03-30T02:30:00+05:30\"\n" + "   },\n"
            + "   \"end\": {\n" + "    \"dateTime\": \"2014-03-30T03:30:00+05:30\"\n" + "   },\n"
            + "   \"iCalUID\": \"q28lprjb8ad3m17955lf1p9d48@google.com\",\n" + "   \"sequence\": 0\n" + "  },\n"
            + "  {\n" + "   \"kind\": \"calendar#event\",\n"
            + "   \"etag\": \"\\\"2DaeHpkENZGECFHdcr5l8tYxjD4/MTM5NjEzMjUzMjQxNzAwMA\\\"\",\n"
            + "   \"id\": \"jgpue3stuo3js5qlsodob84voo\",\n" + "   \"status\": \"confirmed\",\n"
            + "   \"htmlLink\": \"https://www.google.com/calendar/event?eid=amdwdWUzc3R1bzNqczVxbHNvZG9iODR2b28gM3RvcjdvamZxaWhlamNqNjduOWw0dDhnMmNAZw\",\n"
            + "   \"created\": \"2014-03-29T22:35:32.000Z\",\n"
            + "   \"updated\": \"2014-03-29T22:35:32.417Z\",\n" + "   \"summary\": \"Test Events\",\n"
            + "   \"description\": \"Hack!!\",\n"
            + "   \"location\": \"Northeastern University, Huntington Avenue, Boston, MA, United States\",\n"
            + "   \"creator\": {\n" + "    \"email\": \"vrohitrao@gmail.com\",\n"
            + "    \"displayName\": \"Rohith Vallu\"\n" + "   },\n" + "   \"organizer\": {\n"
            + "    \"email\": \"3tor7ojfqihejcj67n9l4t8g2c@group.calendar.google.com\",\n"
            + "    \"displayName\": \"PushEvents\",\n" + "    \"self\": true\n" + "   },\n"
            + "   \"start\": {\n" + "    \"dateTime\": \"2014-03-30T04:30:00+05:30\"\n" + "   },\n"
            + "   \"end\": {\n" + "    \"dateTime\": \"2014-03-30T19:30:00+05:30\"\n" + "   },\n"
            + "   \"visibility\": \"public\",\n"
            + "   \"iCalUID\": \"jgpue3stuo3js5qlsodob84voo@google.com\",\n" + "   \"sequence\": 0\n" + "  }\n"
            + " ]\n" + "}";

    Gson gson = new Gson();
    try {
        JSONObject jsonData = new JSONObject(jsonString);
        JSONArray jsonArray = jsonData.getJSONArray("items");
        JSONObject eventData;
        Event event = new Event();
        for (int i = 0; i < jsonArray.length(); i++) {

            System.out.println(jsonArray.get(i).toString());
            Items item = gson.fromJson(jsonArray.get(i).toString(), Items.class);

            event.setSummary(item.getSummary());
            event.setLocation(item.getLocation());

            /* Will be adding the attendees here
             ArrayList<EventAttendee> attendees = new ArrayList<EventAttendee>();
             attendees.add(new EventAttendee().setEmail("attendeeEmail"));
             // ...
             event.setAttendees(attendees);
             */
            Date startDate = new Date();
            Date endDate = new Date(startDate.getTime() + 3600000);
            DateTime start = new DateTime(startDate, TimeZone.getDefault().getDefault().getTimeZone("UTC"));
            event.setStart(new EventDateTime().setDateTime(start));
            DateTime end = new DateTime(endDate, TimeZone.getTimeZone("UTC"));
            event.setEnd(new EventDateTime().setDateTime(end));
            HttpTransport transport = new NetHttpTransport();
            JsonFactory jsonFactory = new JacksonFactory();
            Calendar.Builder builder = new Calendar.Builder(transport, jsonFactory, null);
            String clientID = "937140966210.apps.googleusercontent.com";
            String redirectURL = "urn:ietf:wg:oauth:2.0:oob";
            String clientSecret = "qMFSb_cadYDG7uh3IDXWiMQY";
            ArrayList<String> scope = new ArrayList<String>();
            scope.add("https://www.googleapis.com/auth/calendar");

            String url = new GoogleAuthorizationCodeRequestUrl(clientID, redirectURL, scope).build();

            System.out.println("Go to the following link in your browser:");
            System.out.println(url);

            // Read the authorization code from the standard input stream.
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("What is the authorization code?");
            String code = in.readLine();

            GoogleTokenResponse response = new GoogleAuthorizationCodeTokenRequest(transport, jsonFactory,
                    clientID, clientSecret, redirectURL, code, redirectURL).execute();

            GoogleCredential credential = new GoogleCredential().setFromTokenResponse(response);

            Calendar service = new Calendar.Builder(transport, jsonFactory, credential).build();

            Event createdEvent = service.events().insert(item.getSummary(), event).execute();

            System.out.println(createdEvent.getId());

        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.traffic.common.utils.http.HttpClientUtils.java

public static void main(String[] args) {
    //cst??GMT?// w  ww . j  a v  a  2s  .c  om
    DateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH);
    format.setTimeZone(TimeZone.getTimeZone("GMT"));
    String date = format.format(new Date());

    String s = "license_plate_num=%E7%B2%A4BA804D&engine_num=C32764&body_num=064484&city_pinyin=shenzhen";
    //??
    String SIGNATURE = MD5Encrypt.encrypt("POST&/v3/violations&" + date + "&" + s.length() + "&"
            + MD5Encrypt.encrypt("uTIYrJn6vJTyt1ztBNbqQQDexDjpAM4m"));
    //
    headers.put("Host", "api.buding.cn");
    headers.put("Authorization", "dLSQ1ZjK7exqlwqx:" + SIGNATURE);
    headers.put("Date", date);

    JSONObject reqParam = new JSONObject();
    reqParam.put("license_plate_num", "BA804D");
    reqParam.put("engine_num", "C32764");
    reqParam.put("body_num", "064484");
    reqParam.put("city_pinyin", "shenzhen");
    String respBody = HttpClientUtils.httpPost_JSONObject("http://api.buding.cn/v3/violations", reqParam);
    System.out.println(JSONObject.parse(respBody));
}

From source file:Main.java

public static String getDeviceTimeZone() {
    Calendar calendar = Calendar.getInstance();
    TimeZone timeZone = calendar.getTimeZone();
    String retString = timeZone.getTimeZone(timeZone.getID()).getID();
    return retString;
}