【问题标题】:SimpleDateFormat from l10n returns NullPointerException in iOS来自 l10n 的 SimpleDateFormat 在 iOS 中返回 NullPointerException
【发布时间】:2016-11-27 12:59:50
【问题描述】:

代码在模拟器和 Android 中运行良好。为 ios 构建并在 iPad 上运行时返回空指针异常。去年最初编写我的应用程序时,这很有效。

   import java.util.Date;
   import com.codename1.l10n.SimpleDateFormat;

   public class StateMachine extends StateMachineBase {

    @Override
        protected void beforeNewSchedule(Form f) {            

            Date today = new Date(System.currentTimeMillis());     
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");     
            String curDate = dateFormat.format(today);        
          }}

控制台输出

java.lang.NullPointerException
   at java_util_GregorianCalendar.computeFields:157
   at java_util_Calendar.complete:406
   at java_util_Calendar.setTimeInMillis:501
   at java_util_Calendar.__INIT__:345
   at java_util_GregorianCalendar.__INIT__:70
   at java_util_Calendar.getInstance:422
   at com_codename1_l10n_SimpleDateFormat.format:282
   at com_codename1_l10n_SimpleDateFormat.format:265
   at userclasses_StateMachine.beforeNewSchedule:51
   at generated_StateMachineBase.beforeShow:178
   at com_codename1_ui_util_UIBuilder_FormListener.run:2813
   at com_codename1_ui_Display.processSerialCalls:1152
   at com_codename1_ui_Display.edtLoopImpl:1096
   at com_codename1_ui_Display.mainEDTLoop:997
   at com_codename1_ui_RunnableWrapper.run:120
   at com_codename1_impl_CodenameOneThread.run:176
   at java_lang_Thread.runImpl:153
Nov 24 07:23:31 Barbaras-iPad MyApplication[1793] <Warning>:

【问题讨论】:

    标签: codenameone


    【解决方案1】:

    这似乎是与this commit 相关的回归,它修复了时区问题并有效地导致了这个级联问题。它似乎只发生在特定的时区,这就是我们看不到这一点的原因。

    目前,我们将旧版本的 VM 部署到服务器以解决此问题,直到我们有更稳定的修复。

    【讨论】:

      【解决方案2】:

      现在可以了!!!非常感谢。

      我的时区是亚利桑那州,如果有帮助,我们永远不会更改为夏令时。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-01-30
        • 2015-10-10
        • 2013-03-29
        • 2020-07-09
        • 1970-01-01
        • 1970-01-01
        • 2021-07-25
        • 2015-05-14
        相关资源
        最近更新 更多