1、获取印度时区的当前时间的毫秒数
public long getCurrentMilliseconds() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Asia/Kolkata"));
return now.toInstant().toEpochMilli();
}
return -1;
}
将字符串格式的时间转换成印度时区的毫秒数
public long getMilliseconds(String timeStr) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
ZoneId zoneId = ZoneId.of("Asia/Kolkata");
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(zoneId);
ZonedDateTime dateTime = ZonedDateTime.parse(timeStr, dtf);
return dateTime.toInstant().toEpochMilli();
}
return -1;
}