在android中只获得毫秒的时间(Get only time in milliseconds in android)
我想检查当前时间是否是00:01 AM然后做一个特定的工作我正在尝试将时间转换为毫秒,当我这样做时,我得到不同日期的不同毫秒值。
我试过这个:
Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(getResources().getString(R.string.zerozero))); cal.set(Calendar.MINUTE, Integer.parseInt(getResources().getString(R.string.one))); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); long alarmtime = cal.getTimeInMillis(); long currenttime = System.currentTimeMillis(); Log.e("Value", "= " + alarmtime + " " + currenttime);
当我执行上述操作时:今天为毫秒:它显示为1458066660000 ,明天为: 1458153060000
那么如何检查当前时间是否为00:01 AM?
如何比较当前时间与给定时间的简单方法..?
谢谢!
I want to check if current time is 00:01AM then do a particular job for that I am trying convert only the time to milliseconds when I do that the I get different milliseconds value for different dates.
I tried this:
Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(getResources().getString(R.string.zerozero))); cal.set(Calendar.MINUTE, Integer.parseInt(getResources().getString(R.string.one))); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); long alarmtime = cal.getTimeInMillis(); long currenttime = System.currentTimeMillis(); Log.e("Value", "= " + alarmtime + " " + currenttime);
When I do the above: milliseconds for today: it shows 1458066660000 and for tomorrow it is :1458153060000
So how to check if current time is 00:01AM or not?
Easy way how to compare current Time with given time..?
Thanks!
原文:https://stackoverflow.com/questions/36036362
最满意答案
exports
变量是您引用它的文件的module.exports
。 因此,当您调用namespace
,它会更改从require
namespace
返回的exports
,而不是从require
ns
返回的exports
。请注意
namespace
如何获取3个参数,但其中的第一行基本上使target
成为可选。 如果你传入target
(你可能想要exports
,或者可能是exports ? window
如果这需要在服务器和客户端都运行),那么它应该做你想要的。The
exports
variable is themodule.exports
for the file you reference it from. So when you callnamespace
, it changesexports
that was returned fromrequire
ingnamespace
, not the one that will be returned fromrequire
ingns
.Notice how
namespace
takes 3 arguments, but the first line in it essentially makestarget
optional. If you pass in thetarget
(you probably wantexports
, or maybeexports ? window
if this needs to run in both server and client), then it should do what you want.
相关问答
更多-
如何在Express中使用Jade的CoffeeScript过滤器?(How do I use Jade's CoffeeScript filters in Express?)[2024-02-18]
您需要将其包含在script标记中: script :coffee-script console.log 'This is coffee script' 参考: http : //jade-lang.com/reference/filters/ You need to include it in a script tag: script :coffee-script console.log 'This is coffee script' Reference: http://jad ... -
是的,CoffeeScript简单地编译成纯JS,使其与node.js完全兼容。 要在节点上运行CoffeeScript,您可以: 键入coffee -c example.coffee进行编译,后跟node example.js来运行编译的JS。 简单地输入coffee example.coffee Yes, CoffeeScript simply compiles into pure JS, making it completely compatible with node.js. To run Coff ...
-
该问题的namespace函数: namespace = (target, name, block) -> [target, name, block] = [(if typeof exports isnt 'undefined' then exports else window), arguments...] if arguments.length < 3 top = target target = target[item] or= {} for item in name.split '. ...
-
是否可以使用CoffeeScript for Node.js来分析我的代码?(Is it possible to profile my code using CoffeeScript for Node.js?)[2023-11-17]
试试--nodejs PARAM 。 参见coffee --help 。 Looks like you can pass the --nodejs command line parameter to coffee and anything after that will get passed directly to node. Thanks to https://twitter.com/#!/oluwie who doesn't want to take credit but told me the ans ... -
exports变量是您引用它的文件的module.exports 。 因此,当您调用namespace ,它会更改从require namespace返回的exports ,而不是从require ns返回的exports 。 请注意namespace如何获取3个参数,但其中的第一行基本上使target成为可选。 如果你传入target (你可能想要exports ,或者可能是exports ? window如果这需要在服务器和客户端都运行),那么它应该做你想要的。 The exports variable ...
-
我发现了一种简单的方法。 它发生在我身上,我可以使用以下Javascript代码实现相同的功能。 var com = {}; com.example = {}; com.example.Person = function () {}; var p = new com.example.Person(); 所以我发现为Example定义一个ObjectWrap类是完全没必要的。 相反,我将其定义为一个简单的对象 v8::Isolate *isolate = v8::Isolate::GetCurrent(); ...
-
是的,你这是错误的方式。 Node.js是服务器端技术。 您正在寻找的是在浏览器上的咖啡脚本中使用RequireJS或CommonJS模块(节点使用的)。 有一个使用CoffeeJ和RequireJS的插件似乎可以做你想要的但我还没有使用它,也无法保证它。 Yes, you are going about this the wrong way. Node.js is a server side technology. What you are looking for is using something l ...
-
最近我遇到了与zappa 0.3.3类似的问题 显然, zappa的创建者正在度假并且不会更新到node.js的当前版本,但您可以使用zappajs 。 这是一个更新的分叉。 npm install zappajs 并使用require('zappajs')而不是require('zappa') 。 Recently I just had a similar problem with zappa 0.3.3 Apparently the creator of zappa is on vacation an ...
-
只需使用QName,就像使用元素名称一样: action.attrib[QName(XMLNamespaces.s, 'mustUnderstand')] = "1" Just use QName, like you do with element names: action.attrib[QName(XMLNamespaces.s, 'mustUnderstand')] = "1"
-
使用RequireJS。 在名为“my-classes.coffee”的文件中,定义名称空间。 define [], -> # You need this if you want it to work in multiple environments. # Otherwise just use `window` to work in the browser. root = exports ? this root.MyClasses = {} 您可以在另一个名为“aa.coffee”的文件 ...