Closed. This question needs details or clarity. It is not currently accepting answers.
For getting the time based on Time Zone , use the below code
Date today = new Date();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
String IST = df.format(today);
i use it and work foe me:
TimeZone tz = TimeZone.getTimeZone("GMT+05:30");
Calendar c = Calendar.getInstance(tz);
String time = String.format("%02d" , c.get(Calendar.HOUR_OF_DAY))+":"+
String.format("%02d" , c.get(Calendar.MINUTE))+":"+
. String.format("%02d" , c.get(Calendar.SECOND))+":"+
. String.format("%03d" , c.get(Calendar.MILLISECOND));
SET TIME ZONE, The SET TIME ZONE keyword allows you to specify a current time offset from Coordinated Universal Time (UTC) for your locale, overriding the operating system Pick a time zone: Falkland Islands. Standard Daylight Saving. Show Me the Time! #N#Bookmark this page! #N#0-10V Dimming Made Easy.
Below code will log device time and time zone. If you need time specific to zone other than device, please use @shiva Snape answer
long milliseconds = System.currentTimeMillis(); //Long.parseLong(name);
java.text.SimpleDateFormat sdff = new java.text.SimpleDateFormat("yyyyMMdd_HHmmss");
Date resultdate = new Date(milliseconds);
Set the Time Zone of a Date in Java, First, we'll obtain the current Instant from the system clock and ZoneId for a time zone name: ? 1. 2. Instant nowUtc = Instant.now();. To change the time zone settings manually on Windows 10, use these steps: Open Settings. Click on Time & Language. Click on Date & time. Turn off the Set time zone automatically toggle switch (if applicable). Use the "Time zone" drop-down menu and select the correct zone setting.
SET TIME ZONE, Use SHOW TIMEZONE to show the session's current time zone. If you set the timezone using POSIX format, the timezone abbreviation you use overrides the Hover your mouse over any of the red dots to see the name of the city and country and current local time. “DST” is displayed if there is Daylight Saving Time at the moment. Click on any red dot and go to that city's page with time, weather, sunrise/set, moon phases and lots more.
Comments Welcome to SO. Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming. You may be able to get help on Super User. Thank .now i would Run a code at a specified time thanks : it is ok but how to get my current date in format yyyy-mm-dd Thank .now i would Run a code at a specified time Thank .now i would Run a code at a specified time