Advertisement
peterbodlev

Untitled

Apr 22nd, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. import java.text.ParseException;
  2. import java.text.SimpleDateFormat;
  3. import java.util.Calendar;
  4. import java.util.Scanner;
  5.  
  6. public class DateFormat2 {
  7.     public static void main(String[] args) throws ParseException {
  8.         Scanner scan = new Scanner(System.in);
  9.         SimpleDateFormat date = new SimpleDateFormat("dd-MM-yyyy");
  10.         String time = scan.nextLine();
  11.         date.parse(time);
  12.         Calendar calendar = Calendar.getInstance();
  13.         calendar.setTime(date.parse(time));
  14.         calendar.add(Calendar.DAY_OF_YEAR, 999);
  15.         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy");
  16.         System.out.println(simpleDateFormat.format(calendar.getTime()));
  17.  
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement