Tutorial example code not compiling

A forum to discuss Java programming related issues and concerns.
no avatar
SteveE
 
Posts: 1
Joined: Thu Nov 08, 2012 7:32 pm
Location: England

Tutorial example code not compiling

by SteveE » Thu Nov 08, 2012 7:40 pm

Hello everyone,

I have been learning JavaSe & FX for only a few months, although I was once a programmer in COBOL, Assembler and Basic, long ago :)

I have been looking at the date/time stuff on TutorialsPoint and have tried a bit of sample code and it does not compile. I gives the error 'IllegalFormatConversionException'.
The code is at URL http://www.tutorialspoint.com/java/java_date_time.htm

It is this;

import java.util.Date;

class DateDemo {
public static void main(String args[]) {
// Instantiate a Date object
Date date = new Date();

// display time and date using toString()
System.out.printf("%tc", "Current Time : ", date);
}
}
Could someone tell me what the problem is.
Thank you.
Don't be encumbered by history, go off and do something wonderful".
Robert Noyce (December 12, 1927 – June 3, 1990)

no avatar
tutorialspoint
Site Admin
 
Posts: 144
Joined: Fri Apr 27, 2007 6:52 pm

by tutorialspoint » Fri Nov 23, 2012 11:00 pm

Sir I have fixed it, here is correct example:

Code: Select all
import java.util.Date;
 
public class DateDemo {
   public static void main(String args[]) {
       // Instantiate a Date object
       Date date = new Date();
       
       // display time and date using toString()
       System.out.println(date.toString());
   }
}

no avatar
ajitpaswan
 
Posts: 11
Joined: Mon Dec 24, 2012 2:41 am
Location: India

by ajitpaswan » Tue Dec 25, 2012 3:32 am

This example is working fine with my ecllipse helios , no errors :lol:

Return to JAVA Lobby

cron