简体   繁体   中英

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

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 "

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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