Language tag parsing support in StringUtils and StringToLocaleConverter

Issue: SPR-16188
This commit is contained in:
Juergen Hoeller
2018-01-25 19:10:31 +01:00
parent c6b0d85a7c
commit ef3f93e84a
6 changed files with 74 additions and 30 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -275,6 +275,16 @@ public class DefaultConversionServiceTests {
assertEquals(Locale.ENGLISH, conversionService.convert("en", Locale.class));
}
@Test
public void testStringToLocaleWithCountry() {
assertEquals(Locale.US, conversionService.convert("en_US", Locale.class));
}
@Test
public void testStringToLocaleWithLanguageTag() {
assertEquals(Locale.US, conversionService.convert("en-US", Locale.class));
}
@Test
public void testStringToCharset() {
assertEquals(StandardCharsets.UTF_8, conversionService.convert("UTF-8", Charset.class));