java 如何将时间转换为长?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6080943/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 14:14:21  来源:igfitidea点击:

How to convert Time to Long?

javaandroidtime

提问by LA_

For ex., I have the following value:

例如,我有以下价值:

Time.valueOf("2:00:00")

how should I convert it to Long? (to be stored in SQLite database as Real)

我应该如何将其转换为Long?(将作为 存储在 SQLite 数据库中Real

java.sql.Timeis used.

java.sql.Time用来。

回答by MByD

Use getTime():

使用getTime()

Time t = Time.valueOf("2:00:00");
long l = t.getTime();