I usually set the date in the @PrePersist hook:

import javax.persistence.Entity;
import javax.persistence.PrePersist;
// others ignored for brevity


@Entity
public class ComparisonReport implements Serializable {

  public static final String TABLE_NAME = "T_COMPARISON_REPORT";
  public static final String COLUMN_CREATED_AT = "CREATED_AT";

  @Column(name = COLUMN_CREATED_AT)
  private LocalDateTime createdAt;

@PrePersist
  protected void prePersist() {
    if (this.createdAt == null) createdAt = LocalDateTime.now();
  }
 //others ignored for brevity
}

Shared with from Codever. 👉 Use the Copy to mine functionality to copy this snippet to your own personal collection and easy manage your code snippets.

Codever is open source on Github ⭐🙏

Project: codever - File: howto-get-started.component.scss

Set margin-left and margin-right to auto to align in center of the page/div and text-align to align the text and image inside of the table headers and cells:

.extensions-table {
  margin-left: auto;
  margin-right: auto;
  th, td {
    width: 8rem;
    text-align: center;
  }
}
Continue Reading ...

Project: codever

Use the @extend directive. In this case the border style is inherited:

.last-search-border {
  border-width: 0.05rem;
  border-style: solid;
  border-color: #495057;
}

.public-bookmarks-last-search {
  @extend .last-search-border;
  background: #f0f2f5;
  color: black;
}

.my-bookmarks-last-search {
  @extend .last-search-border;
  background: linen;
  color: #495057;
}

Reference - https://sass-lang.com/documentation/at-rules/extend


Shared with from Codever. 👉 Use the Copy to mine functionality to copy this snippet to your own personal collection and easy manage your code snippets.

Codever is open source on Github ⭐🙏

Use case

I thought it would be practical to be able to search for search snippets directly from IntelliJ, without having to go to the browser, something like in the following demo:

IntelliJ Plugin - Search snippet from IDE demo
IntelliJ Plugin - Search snippet from IDE demo

The implementation is fairly easy, so let’s see how it’s done.

Continue Reading ...

Use only the date part

In the following example only the date part is set. Time is set to by default to 00:00:00. So the following query compares all entries archived within a day (2021-06-14):

var start = new Date("2021-06-14");
var end = new Date("2021-06-15");

db.call_archive.find({archivedAt: {$gte: start, $lt: end}}).pretty();

Use both date and time

You can also specify the Time in ISO format

  • new Date("<YYYY-mm-ddTHH:MM:ss>") - specifies the datetime in the client’s local timezone and returns the ISODate with the specified datetime in UTC
  • new Date("<YYYY-mm-ddTHH:MM:ssZ>") - specifies the datetime in UTC and returns the ISODate with the specified datetime in UTC
var start = new Date("2021-06-14T13:13:13Z");
var end = new Date("2021-06-14T14:13:13Z");

db.call_archive.find({archivedAt: {$gte: start, $lt: end}}).sort({archivedAt: -1}).pretty(); //sort descending

Reference - https://docs.mongodb.com/manual/reference/method/Date/


Shared with from Codever. 👉 Use the Copy to mine functionality to copy this snippet to your own personal collection and easy manage your code snippets.

Codever is open source on Github ⭐🙏