Home » date

Tag Archives: date

SQL Between, MySQL Between Dates, Not Between

Bipartite Graph

In this example, we will see how to use the BETWEEN operator included in the SQL. 1. Introduction The BETWEEN is a logical operator, often used in the WHERE clause of the SELECT, UPDATE, and DELETE statements, and gives us the ability to specify whether a value is in a given range or not. Syntax SELECT column_name(s) FROM table_name WHERE column_name ...

Read More »

Java 8 Add Days to Current Date Example

Bipartite Graph

1. Introduction Java 8 added a new set of packages to provide a comprehensive date-time model. Java 8 Date-Time API is a JSR-310 implementation. In this example, I will use classes from the java.time and java.time.format packages to demonstrate how to add days to the current date. java.time is the base package which includes a set of date-time classes: LocalDate, LocalDateTime, Instant, Period, Duration, Clock, ZonedDateTime, ...

Read More »

Groovy Date Example

1. Introduction Date operations may be painful in most of the programming languages. You may spend most of your time to convert dates from one format to another one. In Groovy, date operations are very easy. Groovy has lots of functions extended from JDK Date API, this allows us to use date related operations in an easier way. Let’s have ...

Read More »

java.util.Date to java.sql.Date

Bipartite Graph

In this example, we shall show you how to convert a java.util.Date object to a java.sql.Date object. This conversion is usually necessary when a Date object needs to be written in a database. java.util.Date represents a specific instant in time, with millisecond precision. It represents both date and time. java.sql.Date is a wrapper around millisecond value and is used by ...

Read More »

Java Get current date and time

Bipartite Graph

There are a couple of ways to get the current time and date in Java. You may get the number of milliseconds since January 1, 1970, 00:00:00 GMT using System.currentTimeMillis() and calculate the time by yourself (a problem given to beginners, but too much work if you are developing something), you may use a library not included in the JDK ...

Read More »

Get Date

Bipartite Graph

With this example we are going to demonstrate how to get a Date in Java. The class Date represents a specific instant in time, with millisecond precision. In short, to get a Date object you should: Create a new Date object, using the Date() constructor. The constructor allocates a Date object and initializes it so that it represents the time ...

Read More »

Date from specific time

Bipartite Graph

This is an example of how to get a Date from a specific time. The class Date represents a specific instant in time, with millisecond precision. Getting a Date from a specific long time implies that you should: Create a new Date object, using the Date(long date) constructor, with a long parameter. The constructor allocates a Date object and initializes ...

Read More »

Convert Date to millisec

Bipartite Graph

In this example we shall show you how to convert a Date to millisec, that means get the long number of millisec that represent a Date object. A Date object represents a specific instant in time, with millisecond precision. To convert a Date to millisec one should perform the following steps: Create a new Date object, using the Date() constructor, ...

Read More »

Compare Date objects with compareTo method

Bipartite Graph

With this example we are going to demonstrate how to compare Date objects with compareTo method of the Date class. In short, to compare a Date object with another you should: Create a new Date object, using the Date() constructor, that allocates a Date object and initializes it so that it represents the time at which it was allocated, measured ...

Read More »

Compare Date objects with before method

Bipartite Graph

This is an example of how to compare Date objects with before(Date when) API method of Date. Comparing a Date with another Date using before(Date when) method implies that you should: Create a new Date object, using the Date() constructor, that allocates a Date object and initializes it so that it represents the time at which it was allocated, measured ...

Read More »