Cannot set LC_CTYPE to default locale: No such file or directory

When ssh into a production server, Debian, and noticed there is a warning or error as follows: Terminal manpath: can’t set the locale; make sure $LC_* and $LANG are correct mkyong@test-server:~$ Check the server’s locale; there are warning about the LC_CTYPE and LC_ALL variables. Terminal $ locale locale: Cannot set LC_CTYPE to default locale: No …

Read more

Java 8 – How to parse date with LocalDateTime

Here are a few Java 8 examples to parse date with LocalDateTime. First, find the DateTimeFormatter pattern that matches the date format, for example: String str = "2020-01-30 12:30:41"; DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); second, parse it with LocalDateTime.parse DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); String str = "2020-01-30 12:30:41"; LocalDateTime localDateTime = LocalDateTime.parse(str, dtf); 1. …

Read more

How to change the JVM default locale?

In Java, we can use Locale.setDefault() to change the JVM default locale. JavaLocaleExample.java package com.mkyong.locale; import java.util.Locale; public class JavaLocaleExample { public static void main(String[] args) { // get jvm default locale Locale defaultLocale = Locale.getDefault(); System.out.println(defaultLocale); // set jvm locale to china Locale.setDefault(Locale.CHINA); // or like this //Locale.setDefault(new Locale("zh", "cn"); Locale chinaLocale = Locale.getDefault(); …

Read more

Java – ResourceBundle example

The java.util.ResourceBundle is a library used for internationalization (multiple languages). It is able to return messages as per the default Locale configured for the system. Such a functionality is used when one develops systems to be used all over the world. 1. How it works? The library reads a property file based on the locale and name …

Read more

Display a list of countries in Java

In this article, we show you how to use the Locale class to play around the list of countries. P.S Tested with JDK 1.6 1. List of Countries The Locale.getISOCountries() will return a list of all 2-letter country codes defined in ISO 3166. ListCountry.java package com.webmitta.model; import java.util.Locale; public class ListCountry { public static void …

Read more