< prev index next >

src/java.base/share/classes/java/time/format/DateTimeTextProvider.java

Print this page
rev 17279 : [mq]: 8181586

*** 1,7 **** /* ! * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 110,128 **** public int compare(Entry<String, Long> obj1, Entry<String, Long> obj2) { return obj2.getKey().length() - obj1.getKey().length(); // longest to shortest } }; DateTimeTextProvider() {} /** * Gets the provider of text. * * @return the provider, not null */ static DateTimeTextProvider getInstance() { ! return new DateTimeTextProvider(); } /** * Gets the text for the specified field, locale and style * for the purpose of formatting. --- 110,131 ---- public int compare(Entry<String, Long> obj1, Entry<String, Long> obj2) { return obj2.getKey().length() - obj1.getKey().length(); // longest to shortest } }; + // Singleton instance + private static final DateTimeTextProvider INSTANCE = new DateTimeTextProvider(); + DateTimeTextProvider() {} /** * Gets the provider of text. * * @return the provider, not null */ static DateTimeTextProvider getInstance() { ! return INSTANCE; } /** * Gets the text for the specified field, locale and style * for the purpose of formatting.
< prev index next >