score:1
week schemes differ (that’s the whole reason for having a weekfields
class). you are using weekfields.iso
for parsing and then weekfields.of(locale.getdefault())
for printing the individual fields back. that’s gotta give different results sometimes.
according to iso the first week of the year is the first week that contains at least 4 days of the new year. i can reproduce your week of 12 (+1 compared to the parsed week 11) in locales where week 1 is the week containing january 1. this is the case for example in some arabic locales (where the week begins on saturday) and in israel (where the week begins on sunday).
i believe that the solution is simple: use the same weekfields
object for parsing and for printing (or equivalent weekfields
objects).
score:0
new datetimeformatterbuilder()
.appendvalue(chronofield.year, 4)
.appendvalue(chronofield.aligned_week_of_year, 2)
.appendvalue(chronofield.day_of_week, 1)
.toformatter()
localdate.parse(datestring, customformatter).get(chronofield.day_of_week)
Source: stackoverflow.com
Related Query
- YYYYwwe parsed not as expected
- Why does `Array(0,1,2) == Array(0,1,2)` not return the expected result?
- Thread.join not behaving as I expected in scala
- Scala compiler says "error: identifier expected but integer literal found." for () not {}
- Spark-Monotonically increasing id not working as expected in dataframe?
- scala case class equals (==) not working as expected
- Self-join not working as expected with the DataFrame API
- Scala Stdin.readLine() does not seem to work as expected
- IntelliJ Play2 and Scala plugins are not compatible. Makes IntelliJ 12 no longer work as expected
- Return type depending on parameter type (e.g. Await.ready()) does not work as expected
- Scala Option type not inferred as expected
- Concise notation for single arg anonymous function (avoiding underscore) not working as expected
- org.specs2.mock.Mockito matchers are not working as expected
- Polymorphism not working as expected in scala
- RestartFlow in Akka Streams not working as expected
- Implicit function in Scala not working as expected
- directly applying lift function not give expected function
- Parameter value [1234567890] did not match expected type [scala.Option (n/a)]
- Scala map example not working as expected
- JavaConverters is not working as expected as JavaConversions
- Function reference as implicit parameter with default value not as expected
- println with anonymous function not printing expected value
- Scala map method not behaving as expected
- Spark DataFrame filter not working as expected with Random
- Scala return value not what is expected
- Expression of type EmptyNode.type does not conform to expected type SortedList[T]
- Map containing Objects not working as expected Scala
- Scala Singleton not working as expected
- Implicit conversion not behaving as expected
- Method evaluation not behaving as expected
More Query from same tag
- Play.current and slick DatabaseConfig access outside Play controllers
- How to use SBT to run ScalaTest tests against a fat jar?
- SBT: How to make one task depend on another in multi-project builds, and not run in the root project?
- Akka message passing timing
- Scala Play "Can't resolve symbol db"
- Scala : Unable to send message to Kafka (hosted on remote server)
- Compare 2 dataframes in Apache Spark Scala
- Does Play 2.0 disable the catch-all route usage which is provided in 1.x
- Fast and safe conversion from string to numeric types
- Intersect Scala set with set of subtype
- Is there an efficiency penalty when using Scala inner functions within non-tail recursive functions?
- What is the syntax for creating a Map in Scala that uses an enum as a key?
- Relative time for views in Play Framework 2.1
- Scala - extends vs with
- Akka: strategy to mock a component in an integration test
- Passing sys props to Spark 1.5 especially properties with spaces in it
- Composing an immutable list by 'foreach' over a List[JsObject]
- Flag faulty Row in spark dataframe with boolean values
- actors with daemon-style semantics
- "Missing parameter type" in for-comprehension when overloading flatMap
- Scala: Convert a string to string array with and without split given that all special characters except "(" an ")" are allowed
- Is there a way to use map-like syntax for setting variables in non-map code blocks in Scala?
- Scala streams with array/vector performance characteristics
- Why does Akka fail with "IllegalStateException: cannot create children while terminating or terminated" when testing with ScalaTest?
- scala: convert match statement to pattern matching anonymous function - with values
- High-order Scalacheck property
- Sbt building distribution for a project
- silhouette rest seed : how to use a social provider?
- Early initializer `new {} with SomeTrait` fails
- Why Tuple0-22 and Function0-22 instead of a HList