Перевод unix time в date

546
19 сентября 2017, 06:56

Помогите разобраться с отрисовкой графиков через graph view. Имеется время в unix time. Перевожу его в date:

SimpleDateFormat sdf=new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
 series.setOnDataPointTapListener(new OnDataPointTapListener() {
        @Override
        public void onTap(Series series, DataPointInterface dataPointInterface) {
            long epoch = Long.parseLong(Double.toString( dataPointInterface.getX()) );
            Date date1 = new Date( epoch * 1000 );
            String msg=sdf.format(date1)+"\n"+dataPointInterface.getY();
            Toast.makeText(getActivity(),msg,Toast.LENGTH_LONG).show();
        }
    });

Вроде правильно перевожу из unix в date. Наверное не правильно перевожу из date в string? Такой вот лог:

09-17 13:31:38.789 8907-8907/com.example.a1.test3 E/InputEventReceiver: Exception dispatching input event.
09-17 13:31:38.789 8907-8907/com.example.a1.test3 E/MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallback
09-17 13:31:38.790 8907-8907/com.example.a1.test3 E/MessageQueue-JNI: java.lang.NumberFormatException: For input string: "1.430129878E12"
                                                                          at java.lang.Long.parseLong(Long.java:443)
                                                                          at java.lang.Long.parseLong(Long.java:485)
                                                                          at com.example.a1.test3.fragments.Fragment2$2.onTap(Fragment2.java:168)
                                                                          at com.jjoe64.graphview.series.BaseSeries.onTap(BaseSeries.java:308)
                                                                          at com.jjoe64.graphview.GraphView.onTouchEvent(GraphView.java:441)
                                                                          at android.view.View.dispatchTouchEvent(View.java:9943)
                                                                          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
                                                                          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
                                                                          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
                                                                          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
                                                                          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
                                                                          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
                                                                          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
                                                                          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
                                                                          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
                                                                          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
                                                                          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
                                                                          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
                                                                          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
                                                                          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
                                                                          at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
                                                                          at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
                                                                          at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:411)
                                                                          at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1810)
                                                                          at android.app.Activity.dispatchTouchEvent(Activity.java:3061)
                                                                          at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:71)
                                                                          at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:71)
                                                                          at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:373)
                                                                          at android.view.View.dispatchPointerEvent(View.java:10163)
                                                                          at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4434)
                                                                          at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4302)
                                                                          at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3849)
                                                                          at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3902)
                                                                          at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3868)
                                                                          at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3995)
                                                                          at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3876)
                                                                          at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4052)
                                                                          at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3849)
                                                                          at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3902)
                                                                          at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3868)
                                                                          at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3876)
                                                                          at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3849)
                                                                          at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6210)
                                                                          at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6184)
                                                                          at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6145)
                                                                          at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6313)
                                                                          at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
                                                                          at android.os.MessageQueue.nativePollOnce(Native Method)
                                                                          at android.os.MessageQueue.next(MessageQueue.java:323)
                                                                          at android.os.Looper.loop(Looper.java:136)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
09-17 13:31:38.790 8907-8907/com.example.a1.test3 D/AndroidRuntime: Shutting down VM
09-17 13:31:38.790 8907-8907/com.example.a1.test3 E/AndroidRuntime: FATAL EXCEPTION: main
                                                                    Process: com.example.a1.test3, PID: 8907
                                                                    java.lang.NumberFormatException: For input string: "1.430129878E12"
                                                                        at java.lang.Long.parseLong(Long.java:443)
                                                                        at java.lang.Long.parseLong(Long.java:485)
                                                                        at com.example.a1.test3.fragments.Fragment2$2.onTap(Fragment2.java:168)
                                                                        at com.jjoe64.graphview.series.BaseSeries.onTap(BaseSeries.java:308)
                                                                        at com.jjoe64.graphview.GraphView.onTouchEvent(GraphView.java:441)
                                                                        at android.view.View.dispatchTouchEvent(View.java:9943)
                                                                        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
                                                                        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
                                                                        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
                                                                        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
                                                                        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
                                                                        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
                                                                        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
                                                                        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
                                                                        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
                                                                        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
                                                                        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
                                                                        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
                                                                        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
                                                                        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
                                                                        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2669)
                                                                        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
                                                                        at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:411)
                                                                        at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1810)
                                                                        at android.app.Activity.dispatchTouchEvent(Activity.java:3061)
                                                                        at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:71)
                                                                        at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:71)
                                                                        at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:373)
                                                                        at android.view.View.dispatchPointerEvent(View.java:10163)
                                                                        at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4434)
                                                                        at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4302)
                                                                        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3849)
                                                                        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3902)
                                                                        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3868)
                                                                        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3995)
                                                                        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3876)
                                                                        at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4052)
                                                                        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3849)
                                                                        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3902)
                                                                        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3868)
                                                                        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3876)
                                                                        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3849)
                                                                        at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6210)
                                                                        at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6184)
                                                                        at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6145)
                                                                        at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6313)
                                                                        at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
                                                                        at android.os.MessageQueue.nativePollOnce(Native Method)
                                                                        at android.os.MessageQueue.next(MessageQueue.java:323)
                                                                        at android.os.Looper.loop(Looper.java:136)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
09-17 13:31:38.790 8907-8907/com.example.a1.test3 E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
READ ALSO
Проверка permissions на телефонах Xiaomi для API<23

Проверка permissions на телефонах Xiaomi для API<23

Как известно у Xiaomi есть своя система разрешений и работает она до 6 андроида, где новая система запроса разрешений появилась повсеместноЯ...

388
Eclipse RCP создание нового окна

Eclipse RCP создание нового окна

В главном окне (которое появляется после запуска приложения) я должен сделать главное меню, в нем должен быть раздел window, в этом разделе я должен...

251
Java. containsAll для списка массивов

Java. containsAll для списка массивов

Есть список, состоящий из массивов ArrayList<int[]> list1;И второй список поменьше ArrayList<int[]> list2;

279
Как открыть информацию о приложении?

Как открыть информацию о приложении?

Зная имя пакета, хочу открыть информацию о приложении в настройках(где можно остановить приложение, стереть данные, удалить и тп

246