Re: Difference is x years, xx months and xxx days

Stanislav Baiduzhyi <[email protected]> Mon, 25 Jul 2016 14:36:58 +0000
Newsgroups gmane.comp.java.netbeans.devel
Message-ID <CAFHiie4CH-g=QrmJsYhN9PrnhZS9723E6T+GHqYX9vCH5OM8wA@mail.gmail.com>
https://docs.oracle.com/javase/8/docs/api/java/io/PrintStream.html



On Mon, Jul 25, 2016 at 4:27 PM habiler <[email protected]> wrote:

> 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]
>
>
>
>
>