Posts

Showing posts from April, 2011

Java Puzzle : String concatenation

I have simple program to print date after month from now. 1: package com.test; 2:   3: import java.text.ParseException; 4: import java.text.SimpleDateFormat; 5: import java.util.Date; 6:   7: public class Test{ 8: public static void main(String[]args) throws ParseException{ 9: Date currentDate = new Date(); 10: int d = currentDate.getDate(); 11: int month = currentDate.getMonth()+1; 12: int year = currentDate.getYear() +1900; 13: //trying to update to next moth same date 14: Date nextMonthDate = new SimpleDateFormat( "dd-MM-yyyy" ) 15: .parse(d + "-" 16: + month+1 + "-" // increasing month by one to get next month 17: + year); 18: System.out.println( "Current Date = " + currentDate); 19: System.out.println( "Next Month Date = " +nextMonth