2019年7月31日 星期三

[java]日期的年份隱碼

public static String yearToMaskFormat(final Date date)
{
if (date == null)
{
return "";
}
//將年換成星,例:1955/04/01=>****/04/01
final DateFormat df = new SimpleDateFormat("yyyyMMdd");
try
{
return df.format(date).replaceAll("^(\\d{4})(\\d{2})(\\d{2})$", "**** /$2/$3");
}
catch (final Exception e)
{
e.printStackTrace();
}
return "******";

}

沒有留言:

張貼留言

^