Skip to content

Instantly share code, notes, and snippets.

@jpcaruana
Created January 31, 2014 10:35
Show Gist options
  • Save jpcaruana/8729800 to your computer and use it in GitHub Desktop.
Save jpcaruana/8729800 to your computer and use it in GitHub Desktop.
set your Locale in your tests
package fr.barreverte.test;
import org.junit.rules.ExternalResource;
import java.util.Locale;
public class LocaleRule extends ExternalResource {
private final Locale toRestore;
private final Locale forTest;
public LocaleRule(Locale forTest) {
this.toRestore = Locale.getDefault();
this.forTest = forTest;
}
@Override
protected void before() throws Throwable {
Locale.setDefault(forTest);
}
@Override
protected void after() {
Locale.setDefault(toRestore);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment