Created
July 8, 2018 03:09
-
-
Save xcuYao/8f3b64cd3cd1ea3ce66b9031ed642b8a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 民国纪年转公历 | |
* | |
* @param twDateStr | |
*/ | |
private Date dateChange(String twDateStr) { | |
if (StringUtils.isBlank(twDateStr)) { | |
return null; | |
} | |
Calendar calendar = Calendar.getInstance(); | |
SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日"); | |
Date date; | |
try { | |
date = format.parse(twDateStr); | |
calendar.setTime(date); | |
calendar.add(Calendar.YEAR, 1911); | |
return calendar.getTime(); | |
} catch (ParseException e) { | |
e.printStackTrace(); | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment