Commit 64d7633a authored by yanzg's avatar yanzg

默认日期格式的支持

parent c0af6e3f
......@@ -51,8 +51,8 @@ public class AreaHelper {
} else if (fromAreaId.length() != AREA_LENGTH) {
throw new CodeException("地区编码不合法,长度不为9");
}
String ret = fromAreaId.substring(0, length - 1);
String retSimple = getSimple(fromAreaId);
String ret = fromAreaId.substring(0, length);
String retSimple = getSimple(ret);
if (StringHelper.compare(ret, retSimple)) {
return getFull(retSimple);
}
......@@ -66,6 +66,9 @@ public class AreaHelper {
* @return
*/
public static String getSimple(String fromAreaId) {
if (StringHelper.isEmpty(fromAreaId) || fromAreaId.length() <= 3) {
return fromAreaId;
}
return StringHelper.trimEnd(fromAreaId, "00");
}
......
package helper;
import com.yanzuoguang.util.helper.AreaHelper;
import org.junit.Test;
public class TestAreaHelper {
@Test
public void test() {
String from = "100500103";
// from = 1999;
System.out.println(from);
System.out.println(AreaHelper.getSimple(from));
System.out.println(AreaHelper.getAreaId(from));
System.out.println(AreaHelper.getCityId(from));
System.out.println(AreaHelper.getProvinceId(from));
System.out.println(AreaHelper.getCountryId(from));
System.out.println(AreaHelper.getFull(from));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment