Spain - Formatting standards & code snippets

Here is a complete list of standards and formats used in Spain. It includes a full list of ISO codes, number, date, currency, telephone and address formats. You will also get code examples on how to perform the most common formatting operations in Java, C#, JavaScript and PHP. Multiple resource files are made available, mainly the complete list of states, in different formats such as CSV, XML, JSON, HTML and SQL.

What are the ISO-3166-1 codes for Spain?

  • Alpha-2: ES
  • Alpha-3: ESP
  • Numeric: 724
  • Java Locale Code: es_ES
  • .Net CultureInfo Code: es-ES
  • PHP Locale Code: es_ES

What is the official language in Spain?

  • Spanish

What is the date format in Spain?

The date format in Spain is little-endian:

  • Format: d/mm/yyyy
    Ex: 3/12/2014 for December 3rd 2014
Formatting a date in Java:
Locale locale = new Locale("es", "ES");
SimpleDateFormat sdf = new SimpleDateFormat("d/MM/yyyy", locale);
sdf.format(new Date());
Formatting a date in C#:
CultureInfo ci = CultureInfo.GetCultureInfo("es-ES");
DateTime.Now.ToString("d/MM/yyyy", ci);
Formatting a date in JavaScript:
let date = new Date();
date.toLocaleDateString('es-ES');
Formatting a date in PHP:
date("j/m/Y")

What is the time format in Spain?

The time format in Spain is 24-hour notation in most cases.

  • Format: HH:mm[:ss]
    Ex: 09:00 for 09:00AM, and 21:00 for 09:00PM
Formatting time in Java:
Locale locale = new Locale("es", "ES");
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss", locale);
sdf.format(new Date());
Formatting time in C#:
CultureInfo ci = CultureInfo.GetCultureInfo("es-ES");
DateTime.Now.ToString("HH:mm:ss", ci);
Formatting time in JavaScript:
let time = new Date();
date.toLocaleTimeString('es-ES', {hour12: false});
Formatting time in PHP:
date("H:i:s");

What is the numeric format in Spain?

  • Format: 999.999.999,99
    • Group Size: 3
    • Grouping Character: . (dot)
    • Decimal Character: , (comma)
Formatting numbers in Java:
Locale locale = new Locale("es", "S");
NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);
numberFormat.format(999999999.99d);
Formatting numbers in C#:
double d = 999999999.99d;
d.ToString("n", CultureInfo.GetCultureInfo("es-ES")));
Formatting numbers in JavaScript:
let number = 999999999.99;
number.toLocaleString('es-ES');
Formatting numbers in PHP:
$fmt = new NumberFormatter($locale = 'es_ES', NumberFormatter::DECIMAL);
$fmt->format(999999999.99);

What is the currency format in Spain?

  • Format: 999.999.999,99 €
    • Group Size: 3
    • Grouping Character: . (dot)
    • Decimal Character: , (comma)
    • Currency Symbol: €
    • Currency Symbol Position: Before number
    • Currency Name: Euro (EUR)
Formatting currency in Java:
Locale locale = new Locale("es", "ES");
NumberFormat numberFormat = NumberFormat.getCurrencyInstance(locale);
numberFormat.format(999999999.99d);
Formatting currency in C#:
double d = 999999999.99d;
d.ToString("c", CultureInfo.GetCultureInfo("es-ES")));
Formatting currency in JavaScript:
let number = 999999999.99;
number.toLocaleString('es-ES', {currency: 'EUR', style: 'currency'});
Formatting currency in PHP:
fmt = new NumberFormatter($locale = 'es_ES', NumberFormatter::CURRENCY);
$fmt->format(999999999.99);

Download list of provinces for Spain in CSV, JSON, HTML, SQL and XML


List of provinces: HTML - Select Control

----------------------------------
 ISO_3166-2 code + name - Spanish
----------------------------------
<select>
	<option value="ES-C">A Coruña</option>
	<option value="ES-VI">Araba/Álava</option>
	<option value="ES-AB">Albacete</option>
	<option value="ES-A">Alicante/Alacant</option>
	<option value="ES-AL">Almería</option>
	<option value="ES-O">Asturias</option>
	<option value="ES-AV">Ávila</option>
	<option value="ES-BA">Badajoz</option>
	<option value="ES-PM">Balears</option>
	<option value="ES-B">Barcelona</option>
	<option value="ES-BI">Bizkaia</option>
	<option value="ES-BU">Burgos</option>
	<option value="ES-CC">Cáceres</option>
	<option value="ES-CA">Cádiz</option>
	<option value="ES-S">Cantabria</option>
	<option value="ES-CS">Castellón/Castelló</option>
	<option value="ES-CR">Ciudad Real</option>
	<option value="ES-CO">Córdoba</option>
	<option value="ES-CU">Cuenca</option>
	<option value="ES-SS">Gipuzkoa</option>
	<option value="ES-GI">Girona</option>
	<option value="ES-GR">Granada</option>
	<option value="ES-GU">Guadalajara</option>
	<option value="ES-H">Huelva</option>
	<option value="ES-HU">Huesca</option>
	<option value="ES-J">Jaén</option>
	<option value="ES-LO">La Rioja</option>
	<option value="ES-GC">Las Palmas</option>
	<option value="ES-LE">León</option>
	<option value="ES-L">Lleida</option>
	<option value="ES-LU">Lugo</option>
	<option value="ES-M">Madrid</option>
	<option value="ES-MA">Málaga</option>
	<option value="ES-MU">Murcia</option>
	<option value="ES-NA">Navarra/Nafarro</option>
	<option value="ES-OR">Ourense</option>
	<option value="ES-P">Palencia</option>
	<option value="ES-PO">Pontevedra</option>
	<option value="ES-SA">Salamanca</option>
	<option value="ES-TF">Santa Cruz de Tenerife</option>
	<option value="ES-SG">Segovia</option>
	<option value="ES-SE">Sevilla</option>
	<option value="ES-SO">Soria</option>
	<option value="ES-T">Tarragona</option>
	<option value="ES-TE">Teruel</option>
	<option value="ES-TO">Toledo</option>
	<option value="ES-V">Valencia/València</option>
	<option value="ES-VA">Valladolid</option>
	<option value="ES-ZA">Zamora</option>
	<option value="ES-Z">Zaragoza</option>
</select>

List of provinces: CSV

code,name
ES-C,"A Coruña"
ES-VI,"Araba/Álava"
ES-AB,"Albacete"
ES-A,"Alicante/Alacant"
ES-AL,"Almería"
ES-O,"Asturias"
ES-AV,"Ávila"
ES-BA,"Badajoz"
ES-PM,"Balears"
ES-B,"Barcelona"
ES-BI,"Bizkaia"
ES-BU,"Burgos"
ES-CC,"Cáceres"
ES-CA,"Cádiz"
ES-S,"Cantabria"
ES-CS,"Castellón/Castelló"
ES-CR,"Ciudad Real"
ES-CO,"Córdoba"
ES-CU,"Cuenca"
ES-SS,"Gipuzkoa"
ES-GI,"Girona"
ES-GR,"Granada"
ES-GU,"Guadalajara"
ES-H,"Huelva"
ES-HU,"Huesca"
ES-J,"Jaén"
ES-LO,"La Rioja"
ES-GC,"Las Palmas"
ES-LE,"León"
ES-L,"Lleida"
ES-LU,"Lugo"
ES-M,"Madrid"
ES-MA,"Málaga"
ES-MU,"Murcia"
ES-NA,"Navarra/Nafarro"
ES-OR,"Ourense"
ES-P,"Palencia"
ES-PO,"Pontevedra"
ES-SA,"Salamanca"
ES-TF,"Santa Cruz de Tenerife"
ES-SG,"Segovia"
ES-SE,"Sevilla"
ES-SO,"Soria"
ES-T,"Tarragona"
ES-TE,"Teruel"
ES-TO,"Toledo"
ES-V,"Valencia/València"
ES-VA,"Valladolid"
ES-ZA,"Zamora"
ES-Z,"Zaragoza"

List of provinces: JSON

----------------------------------
 ISO-3166-2 code + Name - Spanish
----------------------------------
[
	{code: "ES-C", name: "A Coruña"},
	{code: "ES-VI", name: "Araba/Álava"},
	{code: "ES-AB", name: "Albacete"},
	{code: "ES-A", name: "Alicante/Alacant"},
	{code: "ES-AL", name: "Almería"},
	{code: "ES-O", name: "Asturias"},
	{code: "ES-AV", name: "Ávila"},
	{code: "ES-BA", name: "Badajoz"},
	{code: "ES-PM", name: "Balears"},
	{code: "ES-B", name: "Barcelona"},
	{code: "ES-BI", name: "Bizkaia"},
	{code: "ES-BU", name: "Burgos"},
	{code: "ES-CC", name: "Cáceres"},
	{code: "ES-CA", name: "Cádiz"},
	{code: "ES-S", name: "Cantabria"},
	{code: "ES-CS", name: "Castellón/Castelló"},
	{code: "ES-CR", name: "Ciudad Real"},
	{code: "ES-CO", name: "Córdoba"},
	{code: "ES-CU", name: "Cuenca"},
	{code: "ES-SS", name: "Gipuzkoa"},
	{code: "ES-GI", name: "Girona"},
	{code: "ES-GR", name: "Granada"},
	{code: "ES-GU", name: "Guadalajara"},
	{code: "ES-H", name: "Huelva"},
	{code: "ES-HU", name: "Huesca"},
	{code: "ES-J", name: "Jaén"},
	{code: "ES-LO", name: "La Rioja"},
	{code: "ES-GC", name: "Las Palmas"},
	{code: "ES-LE", name: "León"},
	{code: "ES-L", name: "Lleida"},
	{code: "ES-LU", name: "Lugo"},
	{code: "ES-M", name: "Madrid"},
	{code: "ES-MA", name: "Málaga"},
	{code: "ES-MU", name: "Murcia"},
	{code: "ES-NA", name: "Navarra/Nafarro"},
	{code: "ES-OR", name: "Ourense"},
	{code: "ES-P", name: "Palencia"},
	{code: "ES-PO", name: "Pontevedra"},
	{code: "ES-SA", name: "Salamanca"},
	{code: "ES-TF", name: "Santa Cruz de Tenerife"},
	{code: "ES-SG", name: "Segovia"},
	{code: "ES-SE", name: "Sevilla"},
	{code: "ES-SO", name: "Soria"},
	{code: "ES-T", name: "Tarragona"},
	{code: "ES-TE", name: "Teruel"},
	{code: "ES-TO", name: "Toledo"},
	{code: "ES-V", name: "Valencia/València"},
	{code: "ES-VA", name: "Valladolid"},
	{code: "ES-ZA", name: "Zamora"},
	{code: "ES-Z", name: "Zaragoza"}
]

List of provinces: SQL

-- -----------------------------------------------------
-- Table `province`
-- -----------------------------------------------------
DROP TABLE IF EXISTS province;

CREATE TABLE IF NOT EXISTS province (
  id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  code VARCHAR(6) NOT NULL,
  name VARCHAR(50) NOT NULL,
  PRIMARY KEY (id),
  UNIQUE INDEX id_UNIQUE (id ASC),
  UNIQUE INDEX code_UNIQUE (code ASC)
) ENGINE = InnoDB;

INSERT INTO province (id, code, name) VALUES (null, 'ES-C', 'A Coruña');
INSERT INTO province (id, code, name) VALUES (null, 'ES-VI', 'Araba/Álava');
INSERT INTO province (id, code, name) VALUES (null, 'ES-AB', 'Albacete');
INSERT INTO province (id, code, name) VALUES (null, 'ES-A', 'Alicante/Alacant');
INSERT INTO province (id, code, name) VALUES (null, 'ES-AL', 'Almería');
INSERT INTO province (id, code, name) VALUES (null, 'ES-O', 'Asturias');
INSERT INTO province (id, code, name) VALUES (null, 'ES-AV', 'Ávila');
INSERT INTO province (id, code, name) VALUES (null, 'ES-BA', 'Badajoz');
INSERT INTO province (id, code, name) VALUES (null, 'ES-PM', 'Balears');
INSERT INTO province (id, code, name) VALUES (null, 'ES-B', 'Barcelona');
INSERT INTO province (id, code, name) VALUES (null, 'ES-BI', 'Bizkaia');
INSERT INTO province (id, code, name) VALUES (null, 'ES-BU', 'Burgos');
INSERT INTO province (id, code, name) VALUES (null, 'ES-CC', 'Cáceres');
INSERT INTO province (id, code, name) VALUES (null, 'ES-CA', 'Cádiz');
INSERT INTO province (id, code, name) VALUES (null, 'ES-S', 'Cantabria');
INSERT INTO province (id, code, name) VALUES (null, 'ES-CS', 'Castellón/Castelló');
INSERT INTO province (id, code, name) VALUES (null, 'ES-CR', 'Ciudad Real');
INSERT INTO province (id, code, name) VALUES (null, 'ES-CO', 'Córdoba');
INSERT INTO province (id, code, name) VALUES (null, 'ES-CU', 'Cuenca');
INSERT INTO province (id, code, name) VALUES (null, 'ES-SS', 'Gipuzkoa');
INSERT INTO province (id, code, name) VALUES (null, 'ES-GI', 'Girona');
INSERT INTO province (id, code, name) VALUES (null, 'ES-GR', 'Granada');
INSERT INTO province (id, code, name) VALUES (null, 'ES-GU', 'Guadalajara');
INSERT INTO province (id, code, name) VALUES (null, 'ES-H', 'Huelva');
INSERT INTO province (id, code, name) VALUES (null, 'ES-HU', 'Huesca');
INSERT INTO province (id, code, name) VALUES (null, 'ES-J', 'Jaén');
INSERT INTO province (id, code, name) VALUES (null, 'ES-LO', 'La Rioja');
INSERT INTO province (id, code, name) VALUES (null, 'ES-GC', 'Las Palmas');
INSERT INTO province (id, code, name) VALUES (null, 'ES-LE', 'León');
INSERT INTO province (id, code, name) VALUES (null, 'ES-L', 'Lleida');
INSERT INTO province (id, code, name) VALUES (null, 'ES-LU', 'Lugo');
INSERT INTO province (id, code, name) VALUES (null, 'ES-M', 'Madrid');
INSERT INTO province (id, code, name) VALUES (null, 'ES-MA', 'Málaga');
INSERT INTO province (id, code, name) VALUES (null, 'ES-MU', 'Murcia');
INSERT INTO province (id, code, name) VALUES (null, 'ES-NA', 'Navarra/Nafarro');
INSERT INTO province (id, code, name) VALUES (null, 'ES-OR', 'Ourense');
INSERT INTO province (id, code, name) VALUES (null, 'ES-P', 'Palencia');
INSERT INTO province (id, code, name) VALUES (null, 'ES-PO', 'Pontevedra');
INSERT INTO province (id, code, name) VALUES (null, 'ES-SA', 'Salamanca');
INSERT INTO province (id, code, name) VALUES (null, 'ES-TF', 'Santa Cruz de Tenerife');
INSERT INTO province (id, code, name) VALUES (null, 'ES-SG', 'Segovia');
INSERT INTO province (id, code, name) VALUES (null, 'ES-SE', 'Sevilla');
INSERT INTO province (id, code, name) VALUES (null, 'ES-SO', 'Soria');
INSERT INTO province (id, code, name) VALUES (null, 'ES-T', 'Tarragona');
INSERT INTO province (id, code, name) VALUES (null, 'ES-TE', 'Teruel');
INSERT INTO province (id, code, name) VALUES (null, 'ES-TO', 'Toledo');
INSERT INTO province (id, code, name) VALUES (null, 'ES-V', 'Valencia/València');
INSERT INTO province (id, code, name) VALUES (null, 'ES-VA', 'Valladolid');
INSERT INTO province (id, code, name) VALUES (null, 'ES-ZA', 'Zamora');
INSERT INTO province (id, code, name) VALUES (null, 'ES-Z', 'Zaragoza');

List of provinces: XML

<!-- ISO 3166-2 code + name - Spanish -->
<?xml version="1.0" encoding="UTF-8"?>
<provinces>
	<province>
		<code>ES-C</code>
		<name>A Coruña</name>
	</province>
	<province>
		<code>ES-VI</code>
		<name>Araba/Álava</name>
	</province>
	<province>
		<code>ES-AB</code>
		<name>Albacete</name>
	</province>
	<province>
		<code>ES-A</code>
		<name>Alicante/Alacant</name>
	</province>
	<province>
		<code>ES-AL</code>
		<name>Almería</name>
	</province>
	<province>
		<code>ES-O</code>
		<name>Asturias</name>
	</province>
	<province>
		<code>ES-AV</code>
		<name>Ávila</name>
	</province>
	<province>
		<code>ES-BA</code>
		<name>Badajoz</name>
	</province>
	<province>
		<code>ES-PM</code>
		<name>Balears</name>
	</province>
	<province>
		<code>ES-B</code>
		<name>Barcelona</name>
	</province>
	<province>
		<code>ES-BI</code>
		<name>Bizkaia</name>
	</province>
	<province>
		<code>ES-BU</code>
		<name>Burgos</name>
	</province>
	<province>
		<code>ES-CC</code>
		<name>Cáceres</name>
	</province>
	<province>
		<code>ES-CA</code>
		<name>Cádiz</name>
	</province>
	<province>
		<code>ES-S</code>
		<name>Cantabria</name>
	</province>
	<province>
		<code>ES-CS</code>
		<name>Castellón/Castelló</name>
	</province>
	<province>
		<code>ES-CR</code>
		<name>Ciudad Real</name>
	</province>
	<province>
		<code>ES-CO</code>
		<name>Córdoba</name>
	</province>
	<province>
		<code>ES-CU</code>
		<name>Cuenca</name>
	</province>
	<province>
		<code>ES-SS</code>
		<name>Gipuzkoa</name>
	</province>
	<province>
		<code>ES-GI</code>
		<name>Girona</name>
	</province>
	<province>
		<code>ES-GR</code>
		<name>Granada</name>
	</province>
	<province>
		<code>ES-GU</code>
		<name>Guadalajara</name>
	</province>
	<province>
		<code>ES-H</code>
		<name>Huelva</name>
	</province>
	<province>
		<code>ES-HU</code>
		<name>Huesca</name>
	</province>
	<province>
		<code>ES-J</code>
		<name>Jaén</name>
	</province>
	<province>
		<code>ES-LO</code>
		<name>La Rioja</name>
	</province>
	<province>
		<code>ES-GC</code>
		<name>Las Palmas</name>
	</province>
	<province>
		<code>ES-LE</code>
		<name>León</name>
	</province>
	<province>
		<code>ES-L</code>
		<name>Lleida</name>
	</province>
	<province>
		<code>ES-LU</code>
		<name>Lugo</name>
	</province>
	<province>
		<code>ES-M</code>
		<name>Madrid</name>
	</province>
	<province>
		<code>ES-MA</code>
		<name>Málaga</name>
	</province>
	<province>
		<code>ES-MU</code>
		<name>Murcia</name>
	</province>
	<province>
		<code>ES-NA</code>
		<name>Navarra/Nafarro</name>
	</province>
	<province>
		<code>ES-OR</code>
		<name>Ourense</name>
	</province>
	<province>
		<code>ES-P</code>
		<name>Palencia</name>
	</province>
	<province>
		<code>ES-PO</code>
		<name>Pontevedra</name>
	</province>
	<province>
		<code>ES-SA</code>
		<name>Salamanca</name>
	</province>
	<province>
		<code>ES-TF</code>
		<name>Santa Cruz de Tenerife</name>
	</province>
	<province>
		<code>ES-SG</code>
		<name>Segovia</name>
	</province>
	<province>
		<code>ES-SE</code>
		<name>Sevilla</name>
	</province>
	<province>
		<code>ES-SO</code>
		<name>Soria</name>
	</province>
	<province>
		<code>ES-T</code>
		<name>Tarragona</name>
	</province>
	<province>
		<code>ES-TE</code>
		<name>Teruel</name>
	</province>
	<province>
		<code>ES-TO</code>
		<name>Toledo</name>
	</province>
	<province>
		<code>ES-V</code>
		<name>Valencia/València</name>
	</province>
	<province>
		<code>ES-VA</code>
		<name>Valladolid</name>
	</province>
	<province>
		<code>ES-ZA</code>
		<name>Zamora</name>
	</province>
	<province>
		<code>ES-Z</code>
		<name>Zaragoza</name>
	</province>
</provinces>