Java Code Examples for java.util.Locale#FRANCE

The following examples show how to use java.util.Locale#FRANCE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleDateFormatTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testDayPeriodFormat() throws Exception {
    SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    isoFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date date = isoFormat.parse("2017-01-01T08:00:00");

    for (Locale locale : new Locale[] { Locale.US, Locale.FRANCE }) {
        // Pattern letter 'b'
        assertDayPeriodFormat("HHb", date, "08", locale);
        assertDayPeriodFormat("HHbb", date, "08", locale);
        assertDayPeriodFormat("HHbbb", date, "08", locale);
        assertDayPeriodFormat("HHbbbb", date, "08", locale);
        assertDayPeriodFormat("HHbbbbb", date, "08", locale);

        // Pattern letter 'B'
        assertDayPeriodFormat("HHB", date, "08", locale);
        assertDayPeriodFormat("HHBB", date, "08", locale);
        assertDayPeriodFormat("HHBBB", date, "08", locale);
        assertDayPeriodFormat("HHBBBB", date, "08", locale);
        assertDayPeriodFormat("HHBBBBB", date, "08", locale);
    }
}
 
Example 2
Source File: TCKLocalizedPrinterParser.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name="time")
    Object[][] data_time() {
        return new Object[][] {
                {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.UK},
                {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.US},
                {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.FRANCE},
                {LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.JAPAN},

                {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.UK},
                {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.US},
                {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.FRANCE},
                {LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.JAPAN},

                // these localized patterns include "z" which isn't available from LocalTime
//                {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.UK},
//                {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.US},
//                {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.FRANCE},
//                {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.JAPAN},
//
//                {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.UK},
//                {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.US},
//                {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.FRANCE},
//                {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.JAPAN},
        };
    }
 
Example 3
Source File: ApplicationTest.java    From CompactCalendarView with MIT License 6 votes vote down vote up
@Test
public void testOnDayClickListenerIsCalledWhenLocaleIsFranceWithWedAsFirstDayOFWeek(){
    CompactCalendarViewListener listener = mock(CompactCalendarViewListener.class);
    compactCalendarView.setListener(listener);

    Locale locale = Locale.FRANCE;
    TimeZone timeZone = TimeZone.getTimeZone("Europe/Paris");
    Calendar instance = Calendar.getInstance(timeZone, locale);
    // Thu, 05 Feb 2015 12:00:00 GMT - then set to midnight
    instance.setTimeInMillis(1423137600000L);
    instance.set(Calendar.HOUR_OF_DAY, 0);
    instance.set(Calendar.MINUTE, 0);
    instance.set(Calendar.SECOND, 0);
    instance.set(Calendar.MILLISECOND, 0);

    //Sun, 08 Feb 2015 00:00:00 GMT
    setDate(new Date(1423353600000L));
    setFirstDayOfWeek(Calendar.WEDNESDAY);
    onView(withId(R.id.set_locale)).perform(clickXY(0, 0));
    onView(withId(R.id.compactcalendar_view)).perform(clickXY(60, 100));

    //Thr, 05 Feb 2015 00:00:00 GMT - expected
    verify(listener).onDayClick(instance.getTime());
    verifyNoMoreInteractions(listener);
    takeScreenShot();
}
 
Example 4
Source File: TCKLocalizedPrinterParser.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name="date")
Object[][] data_date() {
    return new Object[][] {
            {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.UK},
            {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.US},
            {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.FRANCE},
            {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.JAPAN},

            {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.UK},
            {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.US},
            {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.FRANCE},
            {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.JAPAN},

            {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.UK},
            {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.US},
            {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.FRANCE},
            {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.JAPAN},

            {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.UK},
            {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.US},
            {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.FRANCE},
            {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.JAPAN},
    };
}
 
Example 5
Source File: TCKLocalizedPrinterParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name="date")
Object[][] data_date() {
    return new Object[][] {
            {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.UK},
            {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.US},
            {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.FRANCE},
            {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.JAPAN},

            {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.UK},
            {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.US},
            {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.FRANCE},
            {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.JAPAN},

            {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.UK},
            {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.US},
            {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.FRANCE},
            {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.JAPAN},

            {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.UK},
            {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.US},
            {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.FRANCE},
            {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.JAPAN},
    };
}
 
Example 6
Source File: TCKLocalizedPrinterParser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name="date")
Object[][] data_date() {
    return new Object[][] {
            {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.UK},
            {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.US},
            {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.FRANCE},
            {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.JAPAN},

            {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.UK},
            {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.US},
            {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.FRANCE},
            {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.JAPAN},

            {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.UK},
            {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.US},
            {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.FRANCE},
            {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.JAPAN},

            {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.UK},
            {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.US},
            {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.FRANCE},
            {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.JAPAN},
    };
}
 
Example 7
Source File: TCKLocalizedPrinterParser.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name="date")
Object[][] data_date() {
    return new Object[][] {
            {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.UK},
            {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.US},
            {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.FRANCE},
            {LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.JAPAN},

            {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.UK},
            {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.US},
            {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.FRANCE},
            {LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.JAPAN},

            {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.UK},
            {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.US},
            {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.FRANCE},
            {LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.JAPAN},

            {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.UK},
            {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.US},
            {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.FRANCE},
            {LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.JAPAN},
    };
}
 
Example 8
Source File: Dates.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
static Locale getLocale(final String l) {
	if (l == null) { return Locale.getDefault(); }
	final String locale = l.toLowerCase();
	switch (locale) {
		case "us":
			return Locale.US;
		case "fr":
			return Locale.FRANCE;
		case "en":
			return Locale.ENGLISH;
		case "de":
			return Locale.GERMAN;
		case "it":
			return Locale.ITALIAN;
		case "jp":
			return Locale.JAPANESE;
		case "uk":
			return Locale.UK;
		default:
			return new Locale(locale);
	}
}
 
Example 9
Source File: AngleFormatTest.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Tests using {@link Locale#FRANCE}.
 */
@Test
public void testFranceLocale() {
    final AngleFormat f = new AngleFormat("DD.ddd°", Locale.FRANCE);
    assertEquals(3, f.getMinimumFractionDigits());
    assertEquals(3, f.getMaximumFractionDigits());
    assertEquals( "DD.ddd°",  f.toPattern());
    assertEquals( "19,457°E", formatAndParse(f, new Longitude( 19.457)));
    assertEquals( "78,124°S", formatAndParse(f, new Latitude (-78.124)));
    assertEquals("-00,010°",  formatAndParse(f, new Angle    (-0.01)));
}
 
Example 10
Source File: I18nApp.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 */
private static Locale chooseLocale()
{
	LocaleWrapper[] locales = 
		new LocaleWrapper[]
		{
			new LocaleWrapper(new Locale("cs", "CZ")),
			new LocaleWrapper(Locale.GERMANY),
			new LocaleWrapper(Locale.US),
			new LocaleWrapper(Locale.FRANCE),
			new LocaleWrapper(new Locale("pt", "PT")),
			new LocaleWrapper(new Locale("ro", "RO")),
			new LocaleWrapper(new Locale("sk", "SK"))
		};
								  
	LocaleWrapper locale = 
		(LocaleWrapper)JOptionPane.showInputDialog(
			null,
			"Choose the locale",
			"Locale",
			JOptionPane.PLAIN_MESSAGE,
			null,
			locales,
			null
			);
	
	if (locale != null)
		return locale.getLocale();
	
	return null;
}
 
Example 11
Source File: RangeFormatTest.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Tests {@link RangeFormat#clone()}.
 */
@Test
public void testClone() {
    final RangeFormat f1 = new RangeFormat(Locale.FRANCE);
    f1.setElementPattern("#0.###", false);
    final RangeFormat f2 = f1.clone();
    f2.setElementPattern("#0.00#", false);
    assertEquals("#0.###", f1.getElementPattern(false));
    assertEquals("#0.00#", f2.getElementPattern(false));
}
 
Example 12
Source File: DateStringsTest.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Test
public void frMonthDayString() {
  Locale locale = Locale.FRANCE;
  startDate = setupLocalizedCalendar(locale, CURRENT_YEAR, 10, 30);
  assertThat(DateStrings.getMonthDay(startDate.getTimeInMillis(), locale), is("30 nov."));
  startDate = setupLocalizedCalendar(locale, CURRENT_YEAR + 1, 5, 25);
  assertThat(DateStrings.getMonthDay(startDate.getTimeInMillis(), locale), is("25 juin"));
  startDate = setupLocalizedCalendar(locale, 2013, 2, 2);
  assertThat(DateStrings.getMonthDay(startDate.getTimeInMillis(), locale), is("2 mars"));
}
 
Example 13
Source File: LocaleTransform.java    From PictureSelector with Apache License 2.0 5 votes vote down vote up
public static Locale getLanguage(int language) {
    switch (language) {
        case LanguageConfig.ENGLISH:
            // 英语-美国
            return Locale.ENGLISH;
        case LanguageConfig.TRADITIONAL_CHINESE:
            // 繁体中文
            return Locale.TRADITIONAL_CHINESE;
        case LanguageConfig.KOREA:
            // 韩语
            return Locale.KOREA;
        case LanguageConfig.GERMANY:
            // 德语
            return Locale.GERMANY;
        case LanguageConfig.FRANCE:
            // 法语
            return Locale.FRANCE;
        case LanguageConfig.JAPAN:
            // 日语
            return Locale.JAPAN;
        case LanguageConfig.VIETNAM:
            // 越南语
            return new Locale("vi");
        default:
            // 简体中文
            return Locale.CHINESE;
    }
}
 
Example 14
Source File: G7CollationTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Test
public void TestG7Data() {
    Locale locales[] = {
            Locale.US,
            Locale.UK,
            Locale.CANADA,
            Locale.FRANCE,
            Locale.CANADA_FRENCH,
            Locale.GERMANY,
            Locale.JAPAN,
            Locale.ITALY
        };
    int i = 0, j = 0;
    for (i = 0; i < locales.length; i++) {
        Collator myCollation= null;
        RuleBasedCollator tblColl1 = null;
        try {
            myCollation = Collator.getInstance(locales[i]);
            tblColl1 = new RuleBasedCollator(((RuleBasedCollator)myCollation).getRules());
        } catch (Exception foo) {
            warnln("Exception: " + foo.getMessage() +
                  "; Locale : " + locales[i].getDisplayName() + " getRules failed");
            continue;
        }
        for (j = 0; j < FIXEDTESTSET; j++) {
            for (int n = j+1; n < FIXEDTESTSET; n++) {
                doTest(tblColl1, testCases[results[i][j]], testCases[results[i][n]], -1);
            }
        }
        myCollation = null;
    }
}
 
Example 15
Source File: StringLibraryTest.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void decimalRepresentationUsingDot() throws Exception {
	Locale french = Locale.FRANCE;
	Double half = NumberFormat.getInstance(french).parse("0,5").doubleValue();
	DecimalFormat decimalFormat = new DecimalFormat("#0.0", new DecimalFormatSymbols(french));
	assertEquals("0,5", decimalFormat.format(half));
	assertEquals("0.5", plainDecimalRepresentation(half));
	
	Double twoAndHalf = NumberFormat.getInstance(french).parse("2,5").doubleValue();
	assertEquals("2,5", decimalFormat.format(twoAndHalf));
	assertEquals("2.5", plainDecimalRepresentation(twoAndHalf));
}
 
Example 16
Source File: DateTimeUtilTest.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
@Test
void localedTimeFrance() {
  DateTimeUtil.defaultLocale = Locale.FRANCE;
  assertThat(DateTimeUtil.getLocalizedTime(), is("14:30:00"));
}
 
Example 17
Source File: SimpleDateFormatUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Test
public void givenFranceLocale_whenFormatted_thenCheckFormatCorrect() throws Exception{
  SimpleDateFormat franceDateFormatter = new SimpleDateFormat("EEEEE dd-MMMMMMM-yyyy", Locale.FRANCE);
  Date myWednesday = new Date(1539341312904L);
  assertTrue(franceDateFormatter.format(myWednesday).startsWith("vendredi"));
}
 
Example 18
Source File: MonthDateFormat.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Some test code.
 *
 * @param args  ignored.
 */
public static void main(String[] args) {
    MonthDateFormat mdf = new MonthDateFormat(Locale.UK, 2);
    System.out.println("UK:");
    System.out.println(mdf.format(new Month(1, 2005).getStart()));
    System.out.println(mdf.format(new Month(2, 2005).getStart()));
    System.out.println(mdf.format(new Month(3, 2005).getStart()));
    System.out.println(mdf.format(new Month(4, 2005).getStart()));
    System.out.println(mdf.format(new Month(5, 2005).getStart()));
    System.out.println(mdf.format(new Month(6, 2005).getStart()));
    System.out.println(mdf.format(new Month(7, 2005).getStart()));
    System.out.println(mdf.format(new Month(8, 2005).getStart()));
    System.out.println(mdf.format(new Month(9, 2005).getStart()));
    System.out.println(mdf.format(new Month(10, 2005).getStart()));
    System.out.println(mdf.format(new Month(11, 2005).getStart()));
    System.out.println(mdf.format(new Month(12, 2005).getStart()));
    System.out.println();

    mdf = new MonthDateFormat(Locale.GERMANY, 2);
    System.out.println("GERMANY:");
    System.out.println(mdf.format(new Month(1, 2005).getStart()));
    System.out.println(mdf.format(new Month(2, 2005).getStart()));
    System.out.println(mdf.format(new Month(3, 2005).getStart()));
    System.out.println(mdf.format(new Month(4, 2005).getStart()));
    System.out.println(mdf.format(new Month(5, 2005).getStart()));
    System.out.println(mdf.format(new Month(6, 2005).getStart()));
    System.out.println(mdf.format(new Month(7, 2005).getStart()));
    System.out.println(mdf.format(new Month(8, 2005).getStart()));
    System.out.println(mdf.format(new Month(9, 2005).getStart()));
    System.out.println(mdf.format(new Month(10, 2005).getStart()));
    System.out.println(mdf.format(new Month(11, 2005).getStart()));
    System.out.println(mdf.format(new Month(12, 2005).getStart()));
    System.out.println();

    mdf = new MonthDateFormat(Locale.FRANCE, 2);
    System.out.println("FRANCE:");
    System.out.println(mdf.format(new Month(1, 2005).getStart()));
    System.out.println(mdf.format(new Month(2, 2005).getStart()));
    System.out.println(mdf.format(new Month(3, 2005).getStart()));
    System.out.println(mdf.format(new Month(4, 2005).getStart()));
    System.out.println(mdf.format(new Month(5, 2005).getStart()));
    System.out.println(mdf.format(new Month(6, 2005).getStart()));
    System.out.println(mdf.format(new Month(7, 2005).getStart()));
    System.out.println(mdf.format(new Month(8, 2005).getStart()));
    System.out.println(mdf.format(new Month(9, 2005).getStart()));
    System.out.println(mdf.format(new Month(10, 2005).getStart()));
    System.out.println(mdf.format(new Month(11, 2005).getStart()));
    System.out.println(mdf.format(new Month(12, 2005).getStart()));
    System.out.println();

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
    sdf.setNumberFormat(null);
    System.out.println(sdf.equals("X"));
}
 
Example 19
Source File: DateAxisTest.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {

    DateAxis a1 = new DateAxis("Test");
    DateAxis a2 = new DateAxis("Test");
    assertTrue(a1.equals(a2));
    assertFalse(a1.equals(null));
    assertFalse(a1.equals("Some non-DateAxis object"));

    a1 = new DateAxis("Test", TimeZone.getTimeZone("PST"), Locale.US);
    assertFalse(a1.equals(a2));
    a2 = new DateAxis("Test", TimeZone.getTimeZone("PST"), Locale.US);
    assertTrue(a1.equals(a2));
    
    a1 = new DateAxis("Test", TimeZone.getTimeZone("PST"), Locale.FRANCE);
    assertFalse(a1.equals(a2));
    a2 = new DateAxis("Test", TimeZone.getTimeZone("PST"), Locale.FRANCE);
    assertTrue(a1.equals(a2));

    // tickUnit
    a1.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7));
    assertFalse(a1.equals(a2));
    a2.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7));
    assertTrue(a1.equals(a2));

    // dateFormatOverride
    a1.setDateFormatOverride(new SimpleDateFormat("yyyy"));
    assertFalse(a1.equals(a2));
    a2.setDateFormatOverride(new SimpleDateFormat("yyyy"));
    assertTrue(a1.equals(a2));

    // tickMarkPosition
    a1.setTickMarkPosition(DateTickMarkPosition.END);
    assertFalse(a1.equals(a2));
    a2.setTickMarkPosition(DateTickMarkPosition.END);
    assertTrue(a1.equals(a2));

    // timeline
    a1.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline());
    assertFalse(a1.equals(a2));
    a2.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline());
    assertTrue(a1.equals(a2));

}
 
Example 20
Source File: DateAxisTest.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {

    DateAxis a1 = new DateAxis("Test");
    DateAxis a2 = new DateAxis("Test");
    assertTrue(a1.equals(a2));
    assertFalse(a1.equals(null));
    assertFalse(a1.equals("Some non-DateAxis object"));

    a1 = new DateAxis("Test", TimeZone.getTimeZone("PST"), Locale.US);
    assertFalse(a1.equals(a2));
    a2 = new DateAxis("Test", TimeZone.getTimeZone("PST"), Locale.US);
    assertTrue(a1.equals(a2));
    
    a1 = new DateAxis("Test", TimeZone.getTimeZone("PST"), Locale.FRANCE);
    assertFalse(a1.equals(a2));
    a2 = new DateAxis("Test", TimeZone.getTimeZone("PST"), Locale.FRANCE);
    assertTrue(a1.equals(a2));

    // tickUnit
    a1.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7));
    assertFalse(a1.equals(a2));
    a2.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7));
    assertTrue(a1.equals(a2));

    // dateFormatOverride
    a1.setDateFormatOverride(new SimpleDateFormat("yyyy"));
    assertFalse(a1.equals(a2));
    a2.setDateFormatOverride(new SimpleDateFormat("yyyy"));
    assertTrue(a1.equals(a2));

    // tickMarkPosition
    a1.setTickMarkPosition(DateTickMarkPosition.END);
    assertFalse(a1.equals(a2));
    a2.setTickMarkPosition(DateTickMarkPosition.END);
    assertTrue(a1.equals(a2));

    // timeline
    a1.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline());
    assertFalse(a1.equals(a2));
    a2.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline());
    assertTrue(a1.equals(a2));

}