title: How to deal with these issues with BigDecimal, String and LocalDate in Java?
body: <p>I am currently getting following exception. The problem is in constructor part of the Price class. How can I deal with this problem. I should be able to pass price 2.29 and date 10202017 as string </p>
  
  <pre><code>Price price = new Price("2.29", "10/20/2017");
  </code></pre>
  
  <p>But the Price class should have </p>
  
  <pre><code>private BigDecimal price;
  private LocalDate effectiveDate;
  </code></pre>
  
  <p>I am not getting good with the conversion. Could anyone show me how to achieve this and guide me.</p>
  
  <p><strong>Desirable output:</strong></p>
  
  <p>Item No: 1 Item: Turkey Sandwich Category: Grocery UPC: 1001 Price: 2.29</p>
  
  <p>Error </p>
  
  <pre><code>Exception in thread "main" java.time.format.DateTimeParseException: Text '10/20/2017' could not be parsed at index 0
      at java.time.format.DateTimeFormatter.parseResolved0(Unknown Source)
      at java.time.format.DateTimeFormatter.parse(Unknown Source)
      at java.time.LocalDate.parse(Unknown Source)
      at java.time.LocalDate.parse(Unknown Source)
      at posPD.Price.&lt;init&gt;(Price.java:35)
      at posTest.MainTest.main(MainTest.java:27)
  </code></pre>
  
  <p>main class</p>
  
  <pre><code>package posTest;
  
  import java.math.BigDecimal;
  
  import posPD.*;
  
  public class MainTest {
  
  
      public static void main(String[] args) {
          // TODO Auto-generated method stub
          Store myStore = new Store("1", "My Store 1");
  
          TaxCategory taxCategory1 = new TaxCategory("Beverages");
          TaxCategory taxCategory2 = new TaxCategory("Grocery");
  
          Register register1 = new Register("Register 1");
          Register register2 = new Register("Register 2");
  
          Person person1 = new Person("David", "OK" ,"405000000",  "800-800-1000");
          Person person2 = new Person("Sally", "Ktm", "123456789", "000-000-0000");
  
  
          Item item = new Item("1", "Turkey Sandwich");
  
  
          Price price = new Price("2.029", "10/20/2017");
  
          UPC upc = new UPC("1001");
          //Price price = new Price("1.49", "2005");
  
          //Session session = new Session();
          try {
  
  
          //CashDrawer cashDraw1 = new CashDrawer(1, BigDecimal.valueOf(500));
  
          //System.out.println(cashDraw1);
          //System.out.println(register.toString());
  
          Cashier cashier1 = new Cashier("1", person1 , "Password1");
          //person1.setCashier(cashier1);
          //myStore.addCashier(cashier);
          Cashier cashier2 = new Cashier("1", person2 , "Password1");
          person1.setCashier(cashier1);
          person2.setCashier(cashier2);
  
          myStore.addCashier(cashier1);
  
          myStore.addCashier(cashier2);
  
  
  
  
          //CashDrawer cashDrawer1 = new CashDrawer("Drawer 1.");
          CashDrawer cashDrawer1 = new CashDrawer(1, BigDecimal.valueOf(500));
          CashDrawer cashDrawer2 = new CashDrawer(2, BigDecimal.valueOf(500));
  
          myStore.addRegister(register1);
          myStore.addRegister(register2);
          register1.setCashDrawer(cashDrawer1);
          register2.setCashDrawer(cashDrawer2);
  
          //myStore.addTaxCategory(taxCategory1);
          //myStore.addTaxCategory(taxCategory2);
  
          Session session1 = new Session(cashier1, register1);
          Session session2 = new Session(cashier2, register2);
  
          myStore.addSession(session1);
          myStore.addSession(session2);
  
          myStore.addItem(item);
          //myStore.addUPC(upc);
          item.addUPC(upc);
  
          //item.addPrice(price);
          item.setTaxCategory(taxCategory2);
  
  
  
  
          //myStore.addCashier(cashier2);
  
          SaleLineItem sli = new SaleLineItem();
  
          System.out.println("=========");
          System.out.println( " "+myStore);
          System.out.println("=========");
  
  
  
          } catch(Exception e) {System.out.println("Exception exists");}
  
      }
  
  }
  </code></pre>
  
  <p>Price class</p>
  
  <pre><code>package posPD;
  
  import java.math.BigDecimal;
  import java.math.RoundingMode;
  import java.time.LocalDate;
  import java.time.LocalDateTime;
  
  /**
   * Price details
   */
  public class Price {
  
      private BigDecimal price;
      private LocalDate effectiveDate;
      private Item item;
  
      public Price() {
          // TODO - implement Price.Price
          //throw new UnsupportedOperationException();
  
      }
  
      /**
       * 
       * @param price
       * @param effectiveDate
       */
      public Price(String price, String effectiveDate) {
          // TODO - implement Price.Price
          //throw new UnsupportedOperationException();
          this();
          BigDecimal bdprice = new BigDecimal (price);
          this.price = bdprice;
  
          LocalDate dt = LocalDate.parse(effectiveDate);
          this.setEffectiveDate(dt);
  
      }
  
      /**
       * 
       * @param date
       */
      public Boolean isEffective(LocalDate date) {
          // TODO - implement Price.isEffective
  
  
          throw new UnsupportedOperationException();
          /*
          if (LocalDate.now().isAfter(date)) {
              return false;
          }
          return true;
          */
  
      }
  
      /**
       * 
       * @param quantity
       */
      public BigDecimal calcAmountForQty(int quantity) {
          // TODO - implement Price.calcAmountForQty
          //throw new UnsupportedOperationException();
  
          return price;
      }
  
      /**
       * 
       * @param date
       */
      /*
      public Boolean isPriceEffectiveForDate(LocalDate date) {
          // TODO - implement Price.isPriceEffectiveForDate
          throw new UnsupportedOperationException();
      }
      */
  
      /**
       * 
       * @param price
       */
      public void compareTo(Price price) {
          // TODO - implement Price.compareTo
          throw new UnsupportedOperationException();
  
      }
  
      public String toString() {
          // TODO - implement Price.toString
          throw new UnsupportedOperationException();
          //return 
      }
  
      public Item getItem() {
          return item;
      }
  
      public void setItem(Item item) {
          this.item = item;
      }
  
      public LocalDate getEffectiveDate() {
          return effectiveDate;
      }
  
      public void setEffectiveDate(LocalDate effectiveDate) {
          this.effectiveDate = effectiveDate;
      }
  
  }
  </code></pre>