test/java/time/test/java/time/format/TestNumberPrinter.java

Print this page

        

@@ -57,39 +57,38 @@
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 package test.java.time.format;
 
-import java.time.format.*;
-
 import static java.time.temporal.ChronoField.DAY_OF_MONTH;
 import static java.time.temporal.ChronoField.HOUR_OF_DAY;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.fail;
 
 import java.time.DateTimeException;
 import java.time.LocalDate;
-import test.java.time.temporal.MockFieldValue;
+import java.time.format.SignStyle;
 
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
+import test.java.time.temporal.MockFieldValue;
 
 /**
  * Test SimpleNumberPrinterParser.
  */
 @Test
 public class TestNumberPrinter extends AbstractTestPrinterParser {
 
     //-----------------------------------------------------------------------
     @Test(expectedExceptions=DateTimeException.class)
     public void test_print_emptyCalendrical() throws Exception {
-        getFormatter(DAY_OF_MONTH, 1, 2, SignStyle.NEVER).printTo(EMPTY_DTA, buf);
+        getFormatter(DAY_OF_MONTH, 1, 2, SignStyle.NEVER).formatTo(EMPTY_DTA, buf);
     }
 
     public void test_print_append() throws Exception {
         buf.append("EXISTING");
-        getFormatter(DAY_OF_MONTH, 1, 2, SignStyle.NEVER).printTo(LocalDate.of(2012, 1, 3), buf);
+        getFormatter(DAY_OF_MONTH, 1, 2, SignStyle.NEVER).formatTo(LocalDate.of(2012, 1, 3), buf);
         assertEquals(buf.toString(), "EXISTING3");
     }
 
     //-----------------------------------------------------------------------
     @DataProvider(name="Pad")

@@ -183,16 +182,16 @@
     }
 
     @Test(dataProvider="Pad")
     public void test_pad_NOT_NEGATIVE(int minPad, int maxPad, long value, String result) throws Exception {
         try {
-            getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.NOT_NEGATIVE).printTo(new MockFieldValue(DAY_OF_MONTH, value), buf);
+            getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.NOT_NEGATIVE).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf);
             if (result == null || value < 0) {
                 fail("Expected exception");
             }
             assertEquals(buf.toString(), result);
-        } catch (DateTimePrintException ex) {
+        } catch (DateTimeException ex) {
             if (result == null || value < 0) {
                 assertEquals(ex.getMessage().contains(DAY_OF_MONTH.getName()), true);
             } else {
                 throw ex;
             }

@@ -200,68 +199,68 @@
     }
 
     @Test(dataProvider="Pad")
     public void test_pad_NEVER(int minPad, int maxPad, long value, String result) throws Exception {
         try {
-            getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.NEVER).printTo(new MockFieldValue(DAY_OF_MONTH, value), buf);
+            getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.NEVER).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf);
             if (result == null) {
                 fail("Expected exception");
             }
             assertEquals(buf.toString(), result);
-        } catch (DateTimePrintException ex) {
+        } catch (DateTimeException ex) {
             if (result != null) {
                 throw ex;
             }
             assertEquals(ex.getMessage().contains(DAY_OF_MONTH.getName()), true);
         }
     }
 
     @Test(dataProvider="Pad")
     public void test_pad_NORMAL(int minPad, int maxPad, long value, String result) throws Exception {
         try {
-            getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.NORMAL).printTo(new MockFieldValue(DAY_OF_MONTH, value), buf);
+            getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.NORMAL).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf);
             if (result == null) {
                 fail("Expected exception");
             }
             assertEquals(buf.toString(), (value < 0 ? "-" + result : result));
-        } catch (DateTimePrintException ex) {
+        } catch (DateTimeException ex) {
             if (result != null) {
                 throw ex;
             }
             assertEquals(ex.getMessage().contains(DAY_OF_MONTH.getName()), true);
         }
     }
 
     @Test(dataProvider="Pad")
     public void test_pad_ALWAYS(int minPad, int maxPad, long value, String result) throws Exception {
         try {
-            getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.ALWAYS).printTo(new MockFieldValue(DAY_OF_MONTH, value), buf);
+            getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.ALWAYS).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf);
             if (result == null) {
                 fail("Expected exception");
             }
             assertEquals(buf.toString(), (value < 0 ? "-" + result : "+" + result));
-        } catch (DateTimePrintException ex) {
+        } catch (DateTimeException ex) {
             if (result != null) {
                 throw ex;
             }
             assertEquals(ex.getMessage().contains(DAY_OF_MONTH.getName()), true);
         }
     }
 
     @Test(dataProvider="Pad")
     public void test_pad_EXCEEDS_PAD(int minPad, int maxPad, long value, String result) throws Exception {
         try {
-            getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.EXCEEDS_PAD).printTo(new MockFieldValue(DAY_OF_MONTH, value), buf);
+            getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.EXCEEDS_PAD).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf);
             if (result == null) {
                 fail("Expected exception");
                 return;  // unreachable
             }
             if (result.length() > minPad || value < 0) {
                 result = (value < 0 ? "-" + result : "+" + result);
             }
             assertEquals(buf.toString(), result);
-        } catch (DateTimePrintException ex) {
+        } catch (DateTimeException ex) {
             if (result != null) {
                 throw ex;
             }
             assertEquals(ex.getMessage().contains(DAY_OF_MONTH.getName()), true);
         }