Ejemplo n.º 1
0
 /**
  * @param string $expected
  * @param string $format
  *
  * @dataProvider testGetDateFormatDataProvider
  */
 public function testFormat($expected, $format)
 {
     $dateFormatter = DateFormatterFactory::getFormatter($format);
     $date = new DateTimeImmutable('1982-01-24');
     $actual = $dateFormatter->format($date, $format);
     $this->assertSame($expected, $actual);
 }
Ejemplo n.º 2
0
 /**
  * @return string
  *
  * @throws UnsupportedDateFormatException
  */
 public function getText()
 {
     try {
         $dateFormat = $this->getDateFormat();
         $dateFormatter = DateFormatterFactory::getFormatter($dateFormat);
         return $dateFormatter->format($this->getDateTime(), $dateFormat);
     } catch (\Exception $e) {
         throw new UnsupportedDateFormatException($this->getDateFormat());
     }
 }