Java - 两个timeMillis之间的差异

时间:2015-09-06 16:41:11

标签: java

如何在几分钟内确定两个timeMillis之间的差异?

我的伪代码是:

long a = System.currentTimeMillis();
long b = MyClass.getPreviusTimeMillis();

double minutes = a - b = ?

2 个答案:

答案 0 :(得分:5)

使用Java 5及更高版本中的TimeUnit enum

var doc = XDocument.Parse(xml);

foreach (var book in doc.Descendants("book"))
{
    Console.WriteLine("Title: {0}", (string) book.Element("title"));
    Console.WriteLine("ISBN: {0}", (string) book.Attribute("ISBN"));
    Console.WriteLine("Price: {0}", (decimal) book.Element("price"));
    Console.WriteLine("---");
}

答案 1 :(得分:1)

分钟差异:double d = (a - b)/60000.0