0
点赞
收藏
分享

微信扫一扫

Android To get local formatting use getDateInstance(), getDateTimeInstance(), or getTimeInstance(),

水墨_青花 2022-04-14 阅读 17
java
  • 告警提示
To get local formatting use getDateInstance(), getDateTimeInstance(), or getTimeInstance(), or use new SimpleDateFormat(String template, Locale locale) with for example Locale.US for ASCII dates. 
Inspection info:Almost all callers should use getDateInstance(), getDateTimeInstance(), or getTimeInstance() to get a ready-made instance of SimpleDateFormat suitable for the user's locale. The main reason you'd create an instance this class directly is because you need to format/parse a specific machine-readable format, in which case you almost certainly want to explicitly ask for US to ensure that you get ASCII digits (rather than, say, Arabic digits).  Therefore, you should either use the form of the SimpleDateFormat constructor where you pass in an explicit locale, such as Locale.US, or use one of the get instance methods, or suppress this error if really know what you are doing.  Issue id: SimpleDateFormat

解决方案

告警代码

在这里插入图片描述

在这里插入图片描述

/** 日期格式,年份-月份-日*/ public static final String DF_STANDARD = "yyyy-MM-dd";

/**日期格式,年份/月份/日*/public static final String DF_STANDARD = "yyyy/MM/dd";

/** 日期格式,年份-月份-日*/ public static final String DF_YYYYMMDD = "yyyyMMdd";
举报

相关推荐

0 条评论