Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
64d7633a
Commit
64d7633a
authored
Aug 28, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
默认日期格式的支持
parent
c0af6e3f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
AreaHelper.java
...src/main/java/com/yanzuoguang/util/helper/AreaHelper.java
+5
-2
TestAreaHelper.java
yzg-util-base/src/test/java/helper/TestAreaHelper.java
+21
-0
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/AreaHelper.java
View file @
64d7633a
...
...
@@ -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"
);
}
...
...
yzg-util-base/src/test/java/helper/TestAreaHelper.java
0 → 100755
View file @
64d7633a
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
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment