2944204 Language util fails to parse some java date formats
Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2944204
This commit is contained in:
parent
f38965f54c
commit
ff099422bd
|
@ -609,21 +609,13 @@ public class Language implements Serializable
|
||||||
m_dateFormat = (SimpleDateFormat)DateFormat.getDateInstance
|
m_dateFormat = (SimpleDateFormat)DateFormat.getDateInstance
|
||||||
(DateFormat.SHORT, m_locale);
|
(DateFormat.SHORT, m_locale);
|
||||||
String sFormat = m_dateFormat.toPattern();
|
String sFormat = m_dateFormat.toPattern();
|
||||||
// some short formats have only one M and d (e.g. ths US)
|
// some short formats have only one M and/or d (e.g. ths US)
|
||||||
if (sFormat.indexOf("MM") == -1 && sFormat.indexOf("dd") == -1)
|
if (sFormat.indexOf("MM") == -1 || sFormat.indexOf("dd") == -1)
|
||||||
{
|
|
||||||
String nFormat = "";
|
|
||||||
for (int i = 0; i < sFormat.length(); i++)
|
|
||||||
{
|
{
|
||||||
if (sFormat.charAt(i) == 'M')
|
sFormat = sFormat.replaceFirst("d+", "dd");
|
||||||
nFormat += "MM";
|
sFormat = sFormat.replaceFirst("M+", "MM");
|
||||||
else if (sFormat.charAt(i) == 'd')
|
|
||||||
nFormat += "dd";
|
|
||||||
else
|
|
||||||
nFormat += sFormat.charAt(i);
|
|
||||||
}
|
|
||||||
// log.finer(sFormat + " => " + nFormat);
|
// log.finer(sFormat + " => " + nFormat);
|
||||||
m_dateFormat.applyPattern(nFormat);
|
m_dateFormat.applyPattern(sFormat);
|
||||||
}
|
}
|
||||||
// Unknown short format => use JDBC
|
// Unknown short format => use JDBC
|
||||||
if (m_dateFormat.toPattern().length() != 8)
|
if (m_dateFormat.toPattern().length() != 8)
|
||||||
|
|
Loading…
Reference in New Issue