Q:

Converting a Unix time stamp to Java date

The code is below:
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    String logTime = format.format(new Date((format.parse("2013-6-30").getTime()+25*24*3600*1000)));
    String logTime1 = format.format(new Date((format.parse("2013-6-30").getTime()+24*24*3600*1000)));
    System.out.println("logTime:  "+logTime);
    System.out.println("logTime1:  "+logTime1);

This is the output:
  logTime:  2013-06-05
  logTime1:  2013-07-24

What is wrong here?

A:

You have an overflow.  Try
25L * 24*3600*1000

so the value is a long.  Your IDE should highlight that what you have will overflow.

this prints a number which is clearly incorrect.
-2134967296

DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
long time = format.parse("2013-6-30").getTime();
String logTime = format.format(new Date(time + 25L * 24 * 3600 * 1000));
String logTime1 = format.format(new Date(time + 24L * 24 * 3600 * 1000));
System.out.println("time + 25d:  " + logTime);
System.out.println("time + 24d:  " + logTime1);

prints
time + 25d:  2013-07-25
time + 24d:  2013-07-24

