Выделяет объект Date и инициализирует его для представления указанного количества миллисекунд, прошедших со стандартного базового времени, известного как "эпоха", а именно 1 января 1970 года, 00:00:00 GMT.
Ответ 2
java.time
В Java 8 представлен новый API для работы с датами и временем: пакет java.time.
С помощью java.time вы можете проанализировать количество целых секунд, прошедших с момента отсчета эпохи в первый момент 1970 года по UTC, 1970-01-01T00:00Z. Результатом является Instant.
Если вам нужно java.util.Date взаимодействовать со старым кодом, который еще не обновлен для java.time, конвертируйте. Вызовите новые методы преобразования, добавленные к старым классам.
You reported getting a time-of-day value of 22:30 instead of the 18:00 seen here. I suspect your PHP utility is implicitly applying a default time zone to adjust from UTC. My value here is UTC, signified by the Z (short for Zulu, means UTC). Any chance your machine OS or PHP is set to Asia/Kabul or Asia/Tehran time zones? I suppose so as you report IRST in your output which apparently means Iran time. Currently in 2017 those are the only zones operating with a summer time that is four and a half hours ahead of UTC.
Specify a proper time zone name in the format of continent/region, such as America/Montreal, Africa/Casablanca, or Pacific/Auckland. Never use the 3-4 letter abbreviation such as EST or IST or IRST as they are not true time zones, not standardized, and not even unique(!).
If you want to see your moment through the lens of a particular region's time zone, apply a ZoneId to get a ZonedDateTime. Still the same simultaneous moment, but seen as a different wall-clock time.
ZoneIdz= ZoneId.of( "Asia/Tehran" ) ; ZonedDateTimezdt= instant.atZone( z ); // Same moment, same point on timeline, but seen as different wall-clock time.
2010-07-30T22:30+04:30[Asia/Tehran]
Converting from java.time to legacy classes
You should stick with the new java.time classes. But you can convert to old if required.
To learn more, see the Oracle Tutorial. And search Stack Overflow for many examples and explanations. Specification is JSR 310.
You may exchange java.time objects directly with your database. Use a JDBC driver compliant with JDBC 4.2 or later. No need for strings, no need for java.sql.* classes.
The ThreeTen-Extra project extends java.time with additional classes. This project is a proving ground for possible future additions to java.time. You may find some useful classes here such as Interval, YearWeek, YearQuarter, and more.