@@ -351,49 +351,49 @@ object Duration {
351351 parsed : String ,
352352 multiplier : Int ,
353353 errorText : String
354- ): Long = {
355- var _parsed = parsed
356- if (_parsed == null )
357- return 0
358- try {
359- if (_parsed.startsWith(" +" ))
360- _parsed = _parsed.substring(1 )
361- val `val` : Long = java.lang.Long .parseLong(_parsed)
362- Math .multiplyExact(`val`, multiplier.toLong)
363- } catch {
364- case ex : NumberFormatException =>
365- throw new DateTimeParseException (s " Text cannot be parsed to a Duration: $errorText" ,
366- text,
367- 0 ,
368- ex)
369- case ex : ArithmeticException =>
370- throw new DateTimeParseException (s " Text cannot be parsed to a Duration: $errorText" ,
371- text,
372- 0 ,
373- ex)
354+ ): Long =
355+ if (parsed == null ) {
356+ 0
357+ } else {
358+ try {
359+ val p =
360+ if (parsed.startsWith(" +" ))
361+ parsed.substring(1 )
362+ else parsed
363+ val v : Long = java.lang.Long .parseLong(p)
364+ Math .multiplyExact(v, multiplier.toLong)
365+ } catch {
366+ case ex : NumberFormatException =>
367+ throw new DateTimeParseException (s " Text cannot be parsed to a Duration: $errorText" ,
368+ text,
369+ 0 ,
370+ ex)
371+ case ex : ArithmeticException =>
372+ throw new DateTimeParseException (s " Text cannot be parsed to a Duration: $errorText" ,
373+ text,
374+ 0 ,
375+ ex)
376+ }
374377 }
375- }
376378
377- private def parseFraction (text : CharSequence , parsed : String , negate : Int ): Int = {
378- var _parsed = parsed
379- if (_parsed == null || _parsed.length == 0 )
380- return 0
381- try {
382- _parsed = (_parsed + " 000000000" ).substring(0 , 9 )
383- _parsed.toInt * negate
384- } catch {
385- case ex : NumberFormatException =>
386- throw new DateTimeParseException (" Text cannot be parsed to a Duration: fraction" ,
387- text,
388- 0 ,
389- ex)
390- case ex : ArithmeticException =>
391- throw new DateTimeParseException (" Text cannot be parsed to a Duration: fraction" ,
392- text,
393- 0 ,
394- ex)
395- }
396- }
379+ private def parseFraction (text : CharSequence , parsed : String , negate : Int ): Int =
380+ if (parsed == null || parsed.length == 0 ) {
381+ 0
382+ } else
383+ try {
384+ (parsed + " 000000000" ).substring(0 , 9 ).toInt * negate
385+ } catch {
386+ case ex : NumberFormatException =>
387+ throw new DateTimeParseException (" Text cannot be parsed to a Duration: fraction" ,
388+ text,
389+ 0 ,
390+ ex)
391+ case ex : ArithmeticException =>
392+ throw new DateTimeParseException (" Text cannot be parsed to a Duration: fraction" ,
393+ text,
394+ 0 ,
395+ ex)
396+ }
397397
398398 private def create (
399399 negate : Boolean ,
0 commit comments