Arghhhhh. Can anyone see what i am doing wrong.The static format method takes a String and an Object[] as arguements. public static String format(String pattern, Object[] arguements) I have to create a Long object and put that into an Object array to pass to the format method but i keep getting a NullPointerException.
Any ideas why?
Sun should have just overloaded the format method to take various datatypes instead of an Object[] array.![]()
Code:class TimeTracker extends TimerTask{ private Timer timer; private Long l; private TimeTrackerTest t; private long millis; Object[] o; public TimeTracker(JTextField jtf){ this.t = t; o = new Object[1]; timer = new Timer(true); } public void run(){ try{ millis = scheduledExecutionTime(); l = new Long(millis); o[0] = l; t.jtf.setText(MessageFormat.format("{0}",o)); }catch(Exception e){System.err.println(e);} } }


The static format method takes a String and an Object[] as arguements. public static String format(String pattern, Object[] arguements) I have to create a Long object and put that into an Object array to pass to the format method but i keep getting a NullPointerException.
Reply With Quote
I was passing the wrong thing into the constructor. Must have been tired.
At least im getting a clean compile now. 