Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

null check with Date object [duplicate]

Tags:

java

date

My method takes a Date object. And I am passing a null value.How can I check if the (Date date) date is null or not.I am new in Stackoverflow, If the question is not a good one please don't undergrade the post.

like image 420
maman Avatar asked Jan 22 '16 10:01

maman


People also ask

How do you check if a date object is null?

Check if it is null: if (date == null) {...} Check if it is not null: if (date !=

How do you check if object is a date?

Checking for Methods that Date Objects Have We can check for methods that date objects have. To do this, we can use the typeof operator. We check that the getMonth method is a function by using the typeof operator to see if it returns 'function' . If it's true , then we know it's likely that date is a Date instance.

How do you check if a value is a date object in node?

You can use the ! isNaN() function to check whether a date is valid. If x is a Date, isNaN(x) is equivalent to Number.


1 Answers

Check if it is null:

if (date == null) {...}

Check if it is not null:

if (date != null) {...}
like image 143
James Avatar answered Sep 22 '22 04:09

James