// this is overkill
Date now = new Date(System.currentTimeMillis());

Why is this overkill?

Recommended Answers

All 8 Replies

Seems ok to me. Who said it was overkill?

(Although I think you should be using the Calendar class instead of Date..)

// this is overkill
Date now = new Date(System.currentTimeMillis());

Why is this overkill?

Because the default constructor for Date implicitly gets you a Date object reference referring to the system date/time at moment of creation.

Doing it like you do here is therefore redundant.

Sorry to post unrelated,but jwenting do you mind checking my java program really quick? (for an intro to java class). I have written it just wwant to confirm its right! (your private messaging is disabled so that's why I posted here. Sorry.

Student 09,

This is very bad to hijack someone else's post. Why don't you post it in a different thread? And why are you addressing directly to a particular member? Why not let the community help you?

BJSJC: You're looking at sql.date. java.util.Date says
Date()
Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.

commented: Oops! Thanks! +5
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.