简体   繁体   English

在Blackberry中将日期转换为毫秒

[英]Convert date to milliseconds in Blackberry

      DateTimePicker datePicker2 = DateTimePicker.createInstance();
      datePicker2.doModal();
      Calendar cal = datePicker2.getDateTime();
      Date date = cal.getTime();
      TimeZone _timeZone = TimeZone.getDefault();

      int month = cal.get(Calendar.MONTH);
      int year = cal.get(Calendar.YEAR);
      int date =cal.get(Calendar.DATE);
      int day = cal.get(Calendar.DAY_OF_WEEK);
      int hour = cal.get(Calendar.HOUR);
      int min = cal.get(Calendar.MINUTE);
      int sec = cal.get(Calendar.SECOND);

      int miliS33 = cal.get(Calendar.MILLISECOND);

I get all fields of selected date using 'datetimepicker` but i just want to convert this date in to milliseconds ,How could i do this..i have already used 我使用'datetimepicker`获取所选日期的所有字段,但我只想将此日期转换为毫秒,我怎么能这样做...我已经使用过

long gmtOffset = _timeZone.getOffset(1, year, month, date,day,miliS); but this does not work for me . 但这对我不起作用。

pls Give suggestion with some code...! 请给出一些代码的建议......!

Just do this: 这样做:

date.getTime();

Remember this method 记住这种方法

"Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT " “返回自1970年1月1日00:00:00 GMT以来的毫秒数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM