0

I am facing problem in auto-generating date. It seems that there is no input on the date after the ID is displayed. It can be run in test class but not in main class. Can anyone help me?

    System.out.println("Your generated item ID is "+itemID);
              java.util.Date time = new java.util.Date();

              SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
              System.out.println("Enter the end time in yyyy-MM-dd HH:mm : ");
              String end = a.nextLine();
              Date end1 = sdf.parse(end);    
//              long end2 = end1.getTime();

              System.out.println(sdf.format(time));
              String aString = sdf.format(time);
              Date now = sdf.parse(aString);
  • Did you read ID using `nextInt()` and now you are trying to read date using `nextLine()`? Also I am assuming `s` is `Scanner`. – Pshemo Jun 01 '16 at 09:12
  • *"It seems that there is no input on the date after the ID is displayed."* And what do you mean by that? I'll provide this link, just to be sure: [Scanner issue when using nextLine after nextXXX](http://stackoverflow.com/q/7056749). – Tom Jun 01 '16 at 09:12

0 Answers0