我正在将一个区域的时间戳转换为另一区域。我得到的是长期价值 作为我们提供的源时间戳。
源日期-> originalDate = 2019-01-09 12:00:42 IST,源的长值---> 1547015442000
在将日期设置为日历后,将获得相同的源长值。
Am使用Output Long值,设置为Apache Kafka中的Object Node
TimeZone timeZone = TimeZone.getTimeZone("UTC");
TimeZone.setDefault(timeZone);
Calendar cal = GregorianCalendar.getInstance(timeZone);
cal.setTime(originalDate);
Calendar result = GregorianCalendar.getInstance(timeZone);
result.set(Calendar.YEAR, cal.get(Calendar.YEAR));
result.set(Calendar.MONTH, cal.get(Calendar.MONTH));
result.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH));
result.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY));
result.set(Calendar.MINUTE, cal.get(Calendar.MINUTE));
result.set(Calendar.SECOND, cal.get(Calendar.SECOND));
result.getTime();
long finalTimestamp = result.getTimeInMillis();
任何帮助将不胜感激。
在此先感谢