开发者

Android equivalent for BlackBerry DateTimeUtilities

开发者 https://www.devze.com 2023-01-08 22:03 出处:网络
Is there an equivalent Android class to the BlackBerry\'s DateTimeUtilities?What I really need is DateTimeUtilities.copyCal(source, dest), and I can write it m开发者_StackOverflow中文版yself, but I re

Is there an equivalent Android class to the BlackBerry's DateTimeUtilities? What I really need is DateTimeUtilities.copyCal(source, dest), and I can write it m开发者_StackOverflow中文版yself, but I really hate writing functions like this only to find it already exists but I just didn't know. I am aware of clone(), but what I really need is to be able to easily change the timezone of a date without having to worry about DST etc myself.


Check out Joda Time - Java date and time API


AFter some further review and fiddling I think this is the easiest way to address this issue for me:

public static long applyLocalTimezoneOffsetMillis(long timestampUTC)
{
    long offset = TimeZone.getDefault().getOffset(timestampUTC);
    return timestampUTC - offset;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消