public function test_appendValueReduced_subsequent_parse()
 {
     $this->builder->appendValue3(CF::MONTH_OF_YEAR(), 1, 2, SignStyle::NORMAL())->appendValueReduced(CF::YEAR(), 2, 2, 2000);
     $f = $this->builder->toFormatter();
     $this->assertEquals($f->__toString(), "Value(MonthOfYear,1,2,NORMAL)ReducedValue(Year,2,2,2000)");
     $ppos = new ParsePosition(0);
     $parsed = $f->parseUnresolved("123", $ppos);
     $this->assertNotNull($parsed, "Parse failed: " . $ppos->__toString());
     $this->assertEquals($parsed->getLong(CF::MONTH_OF_YEAR()), 1);
     $this->assertEquals($parsed->getLong(CF::YEAR()), 2023);
 }
예제 #2
0
 /**
  * @dataProvider data_signStyle
  */
 public function test_signStyle(LocalDate $localDate, SignStyle $style, $expectedEx, $expectedStr)
 {
     $builder = new DateTimeFormatterBuilder();
     $formatter = $builder->appendValue3(ChronoField::YEAR(), 2, 4, $style)->toFormatter();
     $formatter = $formatter->withZone(ZoneOffset::UTC());
     if ($expectedEx === null) {
         $output = $formatter->format($localDate);
         $this->assertEquals($output, $expectedStr);
     } else {
         try {
             $formatter->format($localDate);
             $this->fail();
         } catch (\Exception $ex) {
             $this->assertInstanceOf($expectedEx, $ex);
         }
     }
 }
 public function test_appendValue_3arg_nullSignStyle()
 {
     TestHelper::assertNullException($this, function () {
         $this->builder->appendValue3(ChronoField::DAY_OF_MONTH(), 2, 3, null);
     });
 }
 protected function getFormatterWidth(TemporalField $field, $minWidth, $maxWidth, SignStyle $signStyle)
 {
     return $this->builder->appendValue3($field, $minWidth, $maxWidth, $signStyle)->toFormatter2($this->locale)->withDecimalStyle($this->decimalStyle);
 }