Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

java date-convert timeinmillis to date format

Status
Not open for further replies.

overflo

Technical User
Feb 10, 2003
70
AU
Thanks to Hattusas who showed me the System.currentTimeMillis
Is there an easy way to convert dueDate to a date format(i.e dd-mm-yy)

long dueDate = System.currentTimeMillis() + (86400000 * 14);

Any help appreciated
 
A much simpler method to find today + 14 days and put the date in the correct format :
Code:
  private void calcDate() {
    DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Calendar calendar = Calendar.getInstance();
    System.out.println("Today = " + sdf.format(calendar.getTime()));
    calendar.add(Calendar.DATE,14);
    System.out.println("Today + 14 days = " + sdf.format(calendar.getTime()));
  }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top