T
T
TheKratos2014-10-23 19:21:56
Java
TheKratos, 2014-10-23 19:21:56

Where can I find sample programs in Java?

I want to see the practical application of any features.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander Shpak, 2014-10-23
@shpaker

Github .
ps: cap.

P
ProjectSoft, 2016-12-08
SemenyukS

Or another option without Date, but taking into account the leap year
https://jsfiddle.net/ProjectSoft/qqw8a8g3/
In the default example, the date of a non-leap year is 02/29/2015, which is an error.

V
Vitaly, 2016-12-07
@vshvydky

let stringDate = '12 01 1999';
let parseDate = stringDate.split(' ');

let day = parseInt(parseDate[0], 10);
let month = parseInt(parseDate[1], 10) - 1;
let year = parseInt(parseDate[2], 10);
let d = new Date(year, month, day);
if (day == d.getDate() && month == d.getMonth() && year == d.getFullYear()) {
    console.log(`${stringDate} - YES`);
} else {
    console.error(`${stringDate} - NO`);
}

A
Alexey, 2016-12-08
@alsopub

Can be done like this:

var dt = new Date('2010-02-30');
var ok = !isNaN(dt.getDate());

The bottom line is that if the date does not exist, then getDate() will return NaN.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question