--- /dev/null
+package de.juplo.jpa.converters;
+
+import java.util.Locale;
+import javax.persistence.AttributeConverter;
+import javax.persistence.Converter;
+
+
+/**
+ * Converts a {@link Locale} into its {@link String} representation as a
+ * well-formed IETF BCP 47 language tag.
+ * @author Kai Moritz
+ */
+@Converter(autoApply = true)
+public class LocaleConverter implements AttributeConverter<Locale, String>
+{
+ @Override
+ public String convertToDatabaseColumn(Locale locale)
+ {
+ return locale.toLanguageTag();
+ }
+
+ @Override
+ public Locale convertToEntityAttribute(String string)
+ {
+ return Locale.forLanguageTag(string);
+ }
+}