This is not safe, it will not take in account the leap second.
> 3. as 2, but adjust by timezone offset in millis first to get local
> date.
[quoted text clipped - 3 lines]
> The Java Glossary
> http://mindprod.com
>>> Can anyone please help me with a simple solution?
>>
[quoted text clipped - 6 lines]
>> 3. as 2, but adjust by timezone offset in millis first to get local
>> date.
The OP's only objection to the Calendar class is
> Using Calendar would be possible, but adds a lot of code.
In other words, laziness, even if it were true, which it isn't.
Calendar lets one zero out the time fields, leaving only the date fields filled.
Calendar cal = Calendar.getInstance();
cal.set( Calendar.HOUR, 0 );
cal.set( Calendar.MINUTE, 0 );
cal.set( Calendar.SECOND, 0 );
cal.set( Calendar.MILLISECOND, 0 );
It lets you directly compare one instance to another, using
<http://java.sun.com/javase/6/docs/api/java/util/Calendar.html#compareTo(java.uti
l.Calendar)>
That's going to be a lot less code and a lot more direct than messing with
milliseconds and timezone calculations. This time laziness is steering you in
the direction of *more* work, not less.

Signature
Lew
Ulf - 09 Mar 2008 15:54 GMT
> >>> Can anyone please help me with a simple solution?
>
[quoted text clipped - 30 lines]
> --
> Lew
Thanks for your answers.
The think is that... really I'm lazy... but since I'm converting an
old non Java application that uses a lot of dates without the time
part, I was kind of worried that I missed the simple solution.
I will just include a simple function in my utilities class that uses
Calendar to return a date with time = 0.
/Ulf
Lew - 09 Mar 2008 17:57 GMT
> The think is that... really I'm lazy...
"Laziness" in engineering is actually a virtue. Like other skills, the trick
is knowing when to use it, and which of several alternatives is truly the lazier.
> but since I'm converting an
> old non Java application that uses a lot of dates without the time
> part, I was kind of worried that I missed the simple solution.
In this case, Calendar is the simple solution.

Signature
Lew
Roedy Green - 10 Mar 2008 03:30 GMT
>Calendar lets one zero out the time fields, leaving only the date fields filled.
>
[quoted text clipped - 10 lines]
>milliseconds and timezone calculations. This time laziness is steering you in
>the direction of *more* work, not less.
But if you HAVE to think about timezones to define what you mean by
"today".
What you are doing is looking ahead to the day when the planet uses
UTC without timezones.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
On Sun, 09 Mar 2008 10:45:09 GMT, Andrea Francia
<andrea.francia@gmx.it.invalid> wrote, quoted or indirectly quoted
someone who said :
>> 2. get the timestamp long, and divide by the number of milliseconds in
>> a day to get the day number in GMT.
>This is not safe, it will not take in account the leap second.
leap seconds in Java are handled by adjustments to the clock.
Computationally they don't exist.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Andrea Francia - 10 Mar 2008 10:03 GMT
> leap seconds in Java are handled by adjustments to the clock.
> Computationally they don't exist.
Could you provide a reference for this affirmation, I'm interested.
Thanks
sla29970@gmail.com - 10 Mar 2008 19:09 GMT
On Mar 10, 2:03 am, Andrea Francia <andrea.fran...@gmx.it.invalid>
wrote:
> >leap secondsin Java are handled by adjustments to the clock.
> > Computationally they don't exist.
This is true for a POSIX-compliant system clock. Other system clocks
may count leap seconds.
> Could you provide a reference for this affirmation, I'm interested.
> Thanks
I'll offer these
http://www.ucolick.org/~sla/leapsecs/timescales.html#POSIX
http://www.ucolick.org/~sla/leapsecs/onlinebib.html#POSIX