This discussion is archived
2 Replies Latest reply: Feb 25, 2008 8:54 AM by 807601 RSS

Help with Date format

807601 Newbie
Currently Being Moderated
Hello
I need help with date formatting. Here is my code.

Date date= new Date();
               SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'kk:mm:ss.SS'Z'");
               PositionReport pr = new PositionReport();
               long timeInMilliseconds = pr.getTimeStamp()* 1000;
               date.setTime(timeInMilliseconds);
               String time = dateFormat.format(date.getTime());

When I compile I get the error:
cannot resolve symbol: method format(long)

I get this error at the line that reads:
String time = dateFormat.format(date.getTime());

I have no clue what I am doing wrong. Help!
  • 1. Re: Help with Date format
    807601 Newbie
    Currently Being Moderated
    format only accepts Date as input and not a long. use this:
    String time = dateFormat.format(date);

    Edited by: kimatrix on Feb 25, 2008 4:55 PM
  • 2. Re: Help with Date format
    807601 Newbie
    Currently Being Moderated
    SimpleDateFormat does not have a method 'format' that takes only a long as a parameter. 'Cannot resolve symbol' means that the variable or method you attempted to use does not exist.

    http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html#format(java.util.Date,%20java.lang.StringBuffer,%20java.text.FieldPosition)

    That is the API for SimpleDateFormat. Read it and you'll see that the format() method requires 3 parameters: a Date, a StringBuffer, and a FieldPosition