/**
  * @setUp
  */
 public function setUp()
 {
     $this->builder = new DateTimeFormatterBuilder();
     $this->dta = ZonedDateTime::ofDateTime(LocalDateTime::of(2011, 6, 30, 12, 30, 40, 0), ZoneId::of("Europe/Paris"));
     $this->locale = Locale::of("en");
     $this->decimalStyle = DecimalStyle::STANDARD();
 }
예제 #2
0
 public function test_toString_altered()
 {
     $base = DecimalStyle::of(Locale::US())->withZeroDigit('A')->withDecimalSeparator('@');
     $this->assertEquals($base->__toString(), "DecimalStyle[A+-@]");
 }
 /**
  * @expectedException \OutOfRangeException
  */
 public function test_parseUnresolved_StringParsePosition_invalidPosition()
 {
     $test = $this->fmt->withLocale(Locale::ENGLISH())->withDecimalStyle(DecimalStyle::STANDARD());
     $pos = new ParsePosition(6);
     $test->parseUnresolved("ONE30", $pos);
 }
예제 #4
0
 /**
  * Returns a copy of this formatter with a new DecimalStyle.
  * <p>
  * This instance is immutable and unaffected by this method call.
  *
  * @param DecimalStyle $decimalStyle the new DecimalStyle, not null
  * @return DateTimeFormatter a formatter based on this formatter with the requested DecimalStyle, not null
  */
 public function withDecimalStyle(DecimalStyle $decimalStyle)
 {
     if ($this->decimalStyle->equals($decimalStyle)) {
         return $this;
     }
     return new DateTimeFormatter($this->printerParser, $this->locale, $decimalStyle, $this->resolverStyle, $this->resolverFields, $this->chrono, $this->zone);
 }
 public function test_withLocale_same()
 {
     $base = (new DateTimeFormatterBuilder())->appendLiteral2("ONE")->appendValue3(ChronoField::DAY_OF_MONTH(), 1, 2, SignStyle::NOT_NEGATIVE())->toFormatter2(Locale::ENGLISH())->withDecimalStyle(DecimalStyle::STANDARD());
     $test = $base->withLocale(Locale::ENGLISH());
     $this->assertSame($test, $base);
 }
 protected function getFormatter3(Locale $locale, TextStyle $style, $ci)
 {
     $db = new DateTimeFormatterBuilder();
     if ($ci) {
         $db = $db->parseCaseInsensitive();
     }
     return $db->appendZoneText($style)->toFormatter2($locale)->withDecimalStyle(DecimalStyle::of($locale));
 }
 /**
  * Completes this builder by creating the formatter.
  *
  * @param Locale $locale the locale to use for formatting, not null
  * @param Chronology|null $chrono the chronology to use, may be null
  * @return DateTimeFormatter the created formatter, not null
  */
 private function toFormatter4(Locale $locale, ResolverStyle $resolverStyle, $chrono)
 {
     while ($this->active->parent !== null) {
         $this->optionalEnd();
     }
     $pp = new CompositePrinterParser($this->printerParsers, false);
     return new DateTimeFormatter($pp, $locale, DecimalStyle::STANDARD(), $resolverStyle, null, $chrono, null);
 }