I did a program that connecting to database then show data and user can ( add or remove or update ) data but my problem that program take a little time to be ready how i can know that time and make notification for user to use program now or wait (Program still in loading)

6 Years
Discussion Span
Last Post by mohamed moamen
long start = System.currentTimeMillis();
long end = 0l;
long elapsed = 0l;

// your code

end = System.currentTimeMillis();
elapsed = end - start;
System.out.println(("Search Spent " + ((int) (elapsed / 1000)) + " seconds");

but some Java Gurus told that System.nanoTime(); is more precious


thnx but i do my program using swing controllers and jframeform where i can but this code to calculate all the program time that need to be ready


what you really needed

1) calculate time between two periods,
2) pre-calculate required time and to display that in JProgressBar
3) or entertain the audience (in some way) during the the program works, rotated Icon, change Cursor, diplay some notice...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.