934 setDefault(Category.FORMAT, newLocale);
935 defaultLocale = newLocale;
936 }
937
938 /**
939 * Sets the default locale for the specified Category for this instance
940 * of the Java Virtual Machine. This does not affect the host locale.
941 * <p>
942 * If there is a security manager, its checkPermission method is called
943 * with a PropertyPermission("user.language", "write") permission before
944 * the default locale is changed.
945 * <p>
946 * The Java Virtual Machine sets the default locale during startup based
947 * on the host environment. It is used by many locale-sensitive methods
948 * if no locale is explicitly specified.
949 * <p>
950 * Since changing the default locale may affect many different areas of
951 * functionality, this method should only be used if the caller is
952 * prepared to reinitialize locale-sensitive code running within the
953 * same Java Virtual Machine.
954 * <p>
955 *
956 * @param category - the specified category to set the default locale
957 * @param newLocale - the new default locale
958 * @throws SecurityException - if a security manager exists and its
959 * checkPermission method doesn't allow the operation.
960 * @throws NullPointerException - if category and/or newLocale is null
961 * @see SecurityManager#checkPermission(java.security.Permission)
962 * @see PropertyPermission
963 * @see #getDefault(Locale.Category)
964 * @since 1.7
965 */
966 public static synchronized void setDefault(Locale.Category category,
967 Locale newLocale) {
968 if (category == null)
969 throw new NullPointerException("Category cannot be NULL");
970 if (newLocale == null)
971 throw new NullPointerException("Can't set default locale to NULL");
972
973 SecurityManager sm = System.getSecurityManager();
974 if (sm != null) sm.checkPermission(new PropertyPermission
|
934 setDefault(Category.FORMAT, newLocale);
935 defaultLocale = newLocale;
936 }
937
938 /**
939 * Sets the default locale for the specified Category for this instance
940 * of the Java Virtual Machine. This does not affect the host locale.
941 * <p>
942 * If there is a security manager, its checkPermission method is called
943 * with a PropertyPermission("user.language", "write") permission before
944 * the default locale is changed.
945 * <p>
946 * The Java Virtual Machine sets the default locale during startup based
947 * on the host environment. It is used by many locale-sensitive methods
948 * if no locale is explicitly specified.
949 * <p>
950 * Since changing the default locale may affect many different areas of
951 * functionality, this method should only be used if the caller is
952 * prepared to reinitialize locale-sensitive code running within the
953 * same Java Virtual Machine.
954 *
955 * @param category - the specified category to set the default locale
956 * @param newLocale - the new default locale
957 * @throws SecurityException - if a security manager exists and its
958 * checkPermission method doesn't allow the operation.
959 * @throws NullPointerException - if category and/or newLocale is null
960 * @see SecurityManager#checkPermission(java.security.Permission)
961 * @see PropertyPermission
962 * @see #getDefault(Locale.Category)
963 * @since 1.7
964 */
965 public static synchronized void setDefault(Locale.Category category,
966 Locale newLocale) {
967 if (category == null)
968 throw new NullPointerException("Category cannot be NULL");
969 if (newLocale == null)
970 throw new NullPointerException("Can't set default locale to NULL");
971
972 SecurityManager sm = System.getSecurityManager();
973 if (sm != null) sm.checkPermission(new PropertyPermission
|