前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >SAP UI5的控件DatePicker的DateFormat属性详解

SAP UI5的控件DatePicker的DateFormat属性详解

作者头像
Jerry Wang
发布2020-08-10 10:54:03
3870
发布2020-08-10 10:54:03
举报

This blog contains my research about the date format determination for DatePicker control.

Suppose I have select a new date ( 2015-10-15 ) from DatePicker control, my aim is to figure out the logic how the line 192 has translated dateTapped, “Thu Oct 15 2015” to tempString, “15.10 2015”.

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Kisycath-1596961278344)(https://upload-images.jianshu.io/upload_images/2085791-8eeecb20b5c9e828.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]

aFormatArray

When I debug into this method, I find an array this.aFormatArray.

It contains the date format placeholder as below: “day.month.year”. This is the reason why I get 15.10.2015 as conversion result.

So the question now is, when, where and how is this.aFormatArray populated? Do a text search and I find out it is determined by variable this.oFormatOptions.pattern. In my laptop it has value “dd.MM.yyyy”. Where does this pattern come from?

this.oFormatOptions.pattern

Through debugging we can know the pattern is determined by these three factors:

The pattern is stored in this.mCustomData in LocaleData.js:

this.mCustomData

And this.mCustomData is filled in LocalData.js ‘ constructor function:

getCustomLocaleData function just simply returns mSettings in Configuration.js:

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-AGRpZ9f9-1596961278358)(https://upload-images.jianshu.io/upload_images/2085791-bfa89c2fb90ea1c1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]

mSettings

Now I will look into when the data in this.mSettings will be populated. I find an array M_ABAP_DATE_FORMAT_PATTERN which contains lots of date format options. For my current testing, the format option with key sFormatId = 1 is chosen. Why “1”?

This “1” is configured in my user settings for corresponding ABAP backend system and retrieved via an OData request:

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-561KcNFW-1596961278364)(https://upload-images.jianshu.io/upload_images/2085791-66f8c0d7115f2d5f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]

Now we are ready to go back for checking how is aFormatArray filled by the Date Format DD.MM.YYYY. The logic is, to simply replace each character in this.oFormatOptions.pattern with corresponding hard code value in DateFormat.prototype.oStates:

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-08-09 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • aFormatArray
  • this.oFormatOptions.pattern
  • this.mCustomData
  • mSettings
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档