@@ -46,6 +46,7 @@ public class CouchbaseWeatherSource implements WeatherSource {
4646 private final CouchbaseConnector connector ;
4747 private final IdCoordinateSource coordinateSource ;
4848 private final String coordinateIdColumnName ;
49+ private final String timeStampPattern ;
4950
5051 /**
5152 * Instantiate a weather source utilising a connection to a couchbase instance obtained via the
@@ -57,13 +58,20 @@ public class CouchbaseWeatherSource implements WeatherSource {
5758 * @param coordinateSource Source to obtain actual coordinates from
5859 * @param weatherFactory Factory to transfer field to value mapping into actual java object
5960 * instances
61+ * @param timeStampPattern Pattern of time stamps to parse
6062 */
6163 public CouchbaseWeatherSource (
6264 CouchbaseConnector connector ,
6365 IdCoordinateSource coordinateSource ,
64- TimeBasedWeatherValueFactory weatherFactory ) {
66+ TimeBasedWeatherValueFactory weatherFactory ,
67+ String timeStampPattern ) {
6568 this (
66- connector , coordinateSource , DEFAULT_KEY_PREFIX , DEFAULT_NAMING_CONVENTION , weatherFactory );
69+ connector ,
70+ coordinateSource ,
71+ DEFAULT_KEY_PREFIX ,
72+ DEFAULT_TIMESTAMP_PATTERN ,
73+ DEFAULT_NAMING_CONVENTION ,
74+ weatherFactory );
6775 }
6876
6977 /**
@@ -76,15 +84,22 @@ public CouchbaseWeatherSource(
7684 * @param weatherFactory Factory to transfer field to value mapping into actual java object
7785 * instances
7886 * @deprecated Use {@link CouchbaseWeatherSource#CouchbaseWeatherSource(CouchbaseConnector,
79- * IdCoordinateSource, String, NamingConvention, TimeBasedWeatherValueFactory)} instead
87+ * IdCoordinateSource, String, String, NamingConvention, TimeBasedWeatherValueFactory)}
88+ * instead
8089 */
8190 @ Deprecated
8291 public CouchbaseWeatherSource (
8392 CouchbaseConnector connector ,
8493 IdCoordinateSource coordinateSource ,
8594 String keyPrefix ,
8695 TimeBasedWeatherValueFactory weatherFactory ) {
87- this (connector , coordinateSource , keyPrefix , DEFAULT_NAMING_CONVENTION , weatherFactory );
96+ this (
97+ connector ,
98+ coordinateSource ,
99+ keyPrefix ,
100+ DEFAULT_TIMESTAMP_PATTERN ,
101+ DEFAULT_NAMING_CONVENTION ,
102+ weatherFactory );
88103 }
89104
90105 /**
@@ -94,6 +109,7 @@ public CouchbaseWeatherSource(
94109 * @param connector Connector, that establishes the connection to the couchbase instance
95110 * @param coordinateSource Source to obtain actual coordinates from
96111 * @param keyPrefix Prefix of entries, that belong to weather
112+ * @param timeStampPattern Pattern of time stamps to parse
97113 * @param namingConvention the (case) convention, how columns are named
98114 * @param weatherFactory Factory to transfer field to value mapping into actual java object
99115 * instances
@@ -102,12 +118,14 @@ public CouchbaseWeatherSource(
102118 CouchbaseConnector connector ,
103119 IdCoordinateSource coordinateSource ,
104120 String keyPrefix ,
121+ String timeStampPattern ,
105122 NamingConvention namingConvention ,
106123 TimeBasedWeatherValueFactory weatherFactory ) {
107124 this .connector = connector ;
108125 this .coordinateSource = coordinateSource ;
109126 this .keyPrefix = keyPrefix ;
110127 this .weatherFactory = weatherFactory ;
128+ this .timeStampPattern = timeStampPattern ;
111129 this .coordinateIdColumnName = weatherFactory .getCoordinateIdFieldString (namingConvention );
112130 }
113131
@@ -186,7 +204,7 @@ public Optional<TimeBasedValue<WeatherValue>> getWeather(ZonedDateTime date, Poi
186204 public String generateWeatherKey (ZonedDateTime time , Integer coordinateId ) {
187205 String key = keyPrefix + "::" ;
188206 key += coordinateId + "::" ;
189- key += time .format (DateTimeFormatter .ofPattern (DEFAULT_TIMESTAMP_PATTERN ));
207+ key += time .format (DateTimeFormatter .ofPattern (timeStampPattern ));
190208 return key ;
191209 }
192210
0 commit comments