Date date1 = new Date();Calendar cal = Calendar.getInstance();cal.setTime(date1);double[] coords = db.getCoords(ID1);double latitude = coords[0];double longitude = coords[1];double timezone = -7; /* For Pacific daylight time (GMT - 7)*/ArrayList<String> Times = Class.foo(cal,latitude,longitude,timezone);
我已经安装了JodaTime,甚至在那里我找不到方法.请建议如果本机java或jodatime,或者有办法这样做.
解决方法 当您使用JodaTime创建DateTime时,您不需要传递偏移量.相反,通过时区.它将负责确定正确的偏移量,包括对DST的考虑.// First get a DateTimeZone using the zone nameDateTimeZone zone = DateTimeZone.forID("America/Los_Angeles");// Then get the current time in that zone.DateTime dt = new DateTime(zone);// Or if you prefer to be more explicit,this Syntax is equivalent.DateTime dt = DateTime.Now(zone);
UPDATE
我仍然不确定你在问什么,但也许你正在寻找其中之一:
// To get the current Pacific Time offsetDateTimeZone zone = DateTimeZone.forID("America/Los_Angeles");int currentOffsetMilliseconds = zone.getoffset(Instant.Now());int currentOffsetHours = currentOffsetMilliseconds / (60 * 60 * 1000);// To just determine if it is currently DST in Pacific Time or not.DateTimeZone zone = DateTimeZone.forID("America/Los_Angeles");boolean isstandardOffset = zone.isstandardOffset(Instant.Now());boolean isDaylightOfset = !isstandardOffset;总结
以上是内存溢出为你收集整理的android – jodatime如何知道夏令时是否开启全部内容,希望文章能够帮你解决android – jodatime如何知道夏令时是否开启所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)