Skip to content

Commit

Permalink
FareProduce amount now always displays with two decimal points
Browse files Browse the repository at this point in the history
  • Loading branch information
CaylaSavitzky committed Sep 12, 2024
1 parent fd7fb4a commit a74426a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Optional;
import org.onebusaway.csv_entities.schema.annotations.CsvField;
import org.onebusaway.csv_entities.schema.annotations.CsvFields;
import org.onebusaway.gtfs.serialization.mappings.CurrencyMappingFactory;
import org.onebusaway.gtfs.serialization.mappings.DefaultAgencyIdFieldMappingFactory;
import org.onebusaway.gtfs.serialization.mappings.EntityFieldMappingFactory;
import org.onebusaway.gtfs.serialization.mappings.FareProductFieldMappingFactory;
Expand All @@ -32,7 +33,7 @@ public final class FareProduct extends IdentityBean<AgencyAndId> {
private AgencyAndId fareProductId;
@CsvField(optional = true, name = "fare_product_name")
private String name;
@CsvField
@CsvField(mapping = CurrencyMappingFactory.class)
private float amount = MISSING_VALUE;
@CsvField
private String currency;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.onebusaway.gtfs.serialization.mappings;

import org.onebusaway.csv_entities.schema.DecimalFieldMappingFactory;

import java.util.Locale;

public class CurrencyMappingFactory extends DecimalFieldMappingFactory {
public CurrencyMappingFactory() {
/**
* We override the default locale to en_US so that we always use "." as the
* decimal separator, even in locales that default to using "," insteaad.
*/
super("#######################################.00", null);
}
}

0 comments on commit a74426a

Please sign in to comment.