Difference is x years, xx months and xxx days

"habiler" <[email protected]> Sun, 24 Jul 2016 14:26:07 +0000
Newsgroups gmane.comp.java.netbeans.devel
Message-ID <[email protected]>
Hello to all,
What smatter with my code at line system.out.println.....

Thanks

Habiler


Code:
[quote]
import java.time.*;
/**
 *
 * @author hab
 */
public class NewClass1 {
LocalDate endofCentury = LocalDate.of(2014, 01, 01);
LocalDate now = LocalDate.now();
 
Period diff = Period.between(endofCentury, now);
 
System.out.println("Difference is %d years, %d months and %d days old", 
                    diff.getYears(), diff.getMonths(), diff.getDays());[quote][/quote]



Error : 

Code:

[/quote]Compiling 5 source files to C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\build\classes
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\src\NewClass1.java:13: error: <identifier> expected
System.out.println("Difference is %d years, %d months and %d days old", diff.getYears(), diff.getMonths(), diff.getDays());
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\src\NewClass1.java:13: error: illegal start of type
System.out.println("Difference is %d years, %d months and %d days old", diff.getYears(), diff.getMonths(), diff.getDays());
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\src\NewClass1.java:13: error: <identifier> expected
System.out.println("Difference is %d years, %d months and %d days old", diff.getYears(), diff.getMonths(), diff.getDays());
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\src\NewClass1.java:13: error: ';' expected
System.out.println("Difference is %d years, %d months and %d days old", diff.getYears(), diff.getMonths(), diff.getDays());
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\src\NewClass1.java:13: error: illegal start of type
System.out.println("Difference is %d years, %d months and %d days old", diff.getYears(), diff.getMonths(), diff.getDays());
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\src\NewClass1.java:13: error: ';' expected
System.out.println("Difference is %d years, %d months and %d days old", diff.getYears(), diff.getMonths(), diff.getDays());
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\src\NewClass1.java:13: error: invalid method declaration; return type required
System.out.println("Difference is %d years, %d months and %d days old", diff.getYears(), diff.getMonths(), diff.getDays());
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\src\NewClass1.java:13: error: ';' expected
System.out.println("Difference is %d years, %d months and %d days old", diff.getYears(), diff.getMonths(), diff.getDays());
8 errors
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\nbproject\build-impl.xml:954: The following error occurred while executing this line:
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\nbproject\build-impl.xml:294: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)[quote][

code][/code][/quote]