List of usage examples for java.util TimeZone getDefault
public static TimeZone getDefault()
From source file:Main.java
public static void main(String[] args) { // TimeZone to ZoneId ZoneId defaultZone = TimeZone.getDefault().toZoneId(); System.out.println(defaultZone); }
From source file:Main.java
public static void main(String args[]) { // create object of TimeZone class. TimeZone timezoneobj = TimeZone.getDefault(); System.out.println("Original object: " + timezoneobj); // cloning time zone object Object objClone = timezoneobj.clone(); System.out.println("Clone object: " + objClone); }
From source file:Main.java
public static void main(String args[]) { // create default time zone object TimeZone timezonedefault = TimeZone.getDefault(); // get display name String disname = timezonedefault.getDisplayName(true, TimeZone.LONG); // checking display name System.out.println("Display name is :" + disname); }
From source file:Main.java
public static void main(String args[]) { // create default time zone object TimeZone timezonedefault = TimeZone.getDefault(); // get display name String disname = timezonedefault.getDisplayName(); // checking display name System.out.println("Display name is :" + disname); }
From source file:Main.java
public static void main(String args[]) { // create default time zone object TimeZone timezonedefault = TimeZone.getDefault(); // get display name String disname = timezonedefault.getDisplayName(true, TimeZone.SHORT); // checking display name System.out.println("Display name is :" + disname); }
From source file:Main.java
public static void main(String[] args) { GregorianCalendar cal = new GregorianCalendar(TimeZone.getDefault()); System.out.println(cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { GregorianCalendar cal = new GregorianCalendar(TimeZone.getDefault(), Locale.getDefault()); System.out.println(cal.getTime()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { // Get the current time in Hong Kong Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("Hongkong")); int hour12 = cal.get(Calendar.HOUR); // 0..11 int minutes = cal.get(Calendar.MINUTE); // 0..59 int seconds = cal.get(Calendar.SECOND); // 0..59 boolean am = cal.get(Calendar.AM_PM) == Calendar.AM; // Get the current hour-of-day at GMT cal.setTimeZone(TimeZone.getTimeZone("GMT")); int hour24 = cal.get(Calendar.HOUR_OF_DAY); // 0..23 // Get the current local hour-of-day cal.setTimeZone(TimeZone.getDefault()); hour24 = cal.get(Calendar.HOUR_OF_DAY); // 0..23 }
From source file:gemlite.core.commands.WServer.java
public static void main(String[] args2) throws Exception { String[] defaultArgs = new String[] { "D:/work/data/Gemlite-demo/target/Gemlite-demo-0.0.1-SNAPSHOT.war", "8082", "/" }; defaultArgs = args2 == null || args2.length == 0 ? defaultArgs : args2; ServerConfigHelper.initConfig();/*w w w . ja v a2s.c o m*/ ServerConfigHelper.initLog4j("classpath:log4j2-server.xml"); ServerConfigHelper.setProperty("bind-address", ServerConfigHelper.getConfig(ITEMS.BINDIP)); int port = 8080; String contextPath = "/"; String warPath = ""; if (defaultArgs.length < 1) { LogUtil.getCoreLog().error( "Start error,plelase Start Ws server like this : java gemlite.core.command.WServer /home/ws.war"); return; } warPath = defaultArgs[0]; File file = new File(warPath); if (!file.exists()) { LogUtil.getCoreLog().error("Error input:" + defaultArgs[0] + " war path is not existing!"); return; } if (!file.isFile()) { LogUtil.getCoreLog().error("Error input:" + defaultArgs[0] + " war path is not a valid file!"); return; } if (defaultArgs.length > 1) { port = NumberUtils.toInt(defaultArgs[1]); if (port <= 0 || port >= 65535) { LogUtil.getCoreLog().error( "Port Error:" + defaultArgs[1] + ",not a valid port , make sure port>0 and port<65535"); return; } } if (defaultArgs.length > 2) { contextPath += StringUtils.replace(defaultArgs[2], "/", ""); } try { // jetty_home String jetty_home = ServerConfigHelper.getConfig(ITEMS.GS_WORK) + File.separator + "jetty_home"; jetty_home += File.separator + StringUtils.replace(contextPath, "/", "") + port; File jfile = new File(jetty_home); jfile.mkdirs(); System.setProperty("jetty.home", jetty_home); String jetty_logs = jetty_home + File.separator + "logs" + File.separator; File logsFile = new File(jetty_logs); logsFile.mkdirs(); System.setProperty("jetty.logs", jetty_logs); Server server = new Server(); HttpConfiguration config = new HttpConfiguration(); ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(config)); connector.setReuseAddress(true); connector.setIdleTimeout(30000); connector.setPort(port); server.addConnector(connector); WebAppContext webapp = new WebAppContext(); webapp.setContextPath(contextPath); webapp.setWar(warPath); String tmpStr = jetty_home + File.separator + "webapps" + File.separator; File tmpDir = new File(tmpStr); tmpDir.mkdirs(); webapp.setTempDirectory(tmpDir); // ??? // webapp.setExtraClasspath(extrapath); webapp.setParentLoaderPriority(true); // ?Log RequestLogHandler requestLogHandler = new RequestLogHandler(); NCSARequestLog requestLog = new NCSARequestLog( jetty_logs + File.separator + "jetty-yyyy_mm_dd.request.log"); requestLog.setRetainDays(30); requestLog.setAppend(true); requestLog.setExtended(false); requestLog.setLogTimeZone(TimeZone.getDefault().getID()); requestLogHandler.setRequestLog(requestLog); webapp.setHandler(requestLogHandler); ContextHandler ch = webapp.getServletContext().getContextHandler(); ch.setLogger(new Slf4jLog("gemlite.coreLog")); server.setHandler(webapp); server.start(); System.out.println("-----------------------------------------------------"); LogUtil.getCoreLog().info("Ws Server started,You can visite -> http://" + ServerConfigHelper.getConfig(ITEMS.BINDIP) + ":" + port + contextPath); server.join(); } catch (Exception e) { LogUtil.getCoreLog().error("Ws Server error:", e); } }
From source file:calendarevent.CalendarEvent.java
/** * @param args the command line arguments *//*from w w w. ja v a2s . c om*/ 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(); } }