Q:

Strange behavior of time in Java

I have a very strange problem.  I wrote the following code:
public static final long ONE_DAY_IN_MS = 86400000L;

public static long getTimeOfTheDayInMs() {
    return System.currentTimeMillis() % ONE_DAY_IN_MS;
}

This should return the milliseconds since midnight, right? 
Well, yes and no, since it returns the time since midnight less one hour. 
Why is that?  Why this code:
System.out.println(new Date(System.currentTimeMillis()));
System.out.println(new Date(getTimeOfTheDayInMs()));

returns this?? 
18-jul-2013 12.34.03
1-jan-1970 11.34.03

I also discovered that this issue seems to appear from 30 March 1992. 
Has anyone else the same problem as mine?  Can someone explain me why? 
Thanks in advance,
PS: This issue appears me both in my Windows PC and in my Android tablet. 

A:

Your getTimeOfTheDayInMs() does not return the milliseconds since midnight.  The epoch is 1970 and currentTimeMillis() is relative to that.  Use Calendar http://developer.android.com/reference/java/util/Calendar.html for getting second etc fields.