ABAP JSON Writer使用不正确的日期和时间输出?

时间:2017-07-14 09:33:13

标签: json abap

Valid JSON data types不包括日期。那么SAP为什么要添加' - '?

public class TempActivity extends AppCompatActivity {

    public List<FragmentCommunicator> fragmentCommunicators = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_temp);

    final Spinner spinner1 = (Spinner) findViewById(R.id.spinner1);
    spinner1.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, new String[]{"Value One", "Value Two", "Value Three"}));
   spinner1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
       @Override
       public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

           for (FragmentCommunicator fragmentCommunicator : fragmentCommunicators) {
               fragmentCommunicator.passDataToFragment(spinner1.getSelectedItem().toString());
           }

       }

       @Override
       public void onNothingSelected(AdapterView<?> adapterView) {

       }
   });

   ViewPager viewPager1 = (ViewPager) findViewById(R.id.viewPager1);
   FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager());
   adapter.addFragment(new FirstFragment(), "FirstFragment");
   adapter.addFragment(new SecondFragment(), "SecondFragment");
   adapter.addFragment(new ThirdFragment(), "ThirdFragment");
   viewPager1.setAdapter(adapter);

   viewPager1.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
       @Override
       public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

       }

       @Override
       public void onPageSelected(int position) {

           for (FragmentCommunicator fragmentCommunicator : fragmentCommunicators) {
               fragmentCommunicator.passDataToFragment(spinner1.getSelectedItem().toString());
           }

       }

       @Override
       public void onPageScrollStateChanged(int state) {

       }
   });
 }
}

结果“YYYY-MM-DD”代替“YYYYMMDD”

为什么? 我该如何解决这个问题?

1 个答案:

答案 0 :(得分:3)

JSON没有定义数据类型是对的。 SAP选择将日期表示为字符串,这是一个完全有效的选择,并且至少部分符合ISO 8601 approach favored by other implementations。除了接收应用程序之外,我不相信有任何“修复”的内容。