A quick and practical guide to getting difference between two dates in Scala.
Also find me here:
Baeldung Author
baeldung
This is the standard author on the site. Most articles are published by individual authors, with their own profiles, but when multiple people have a strong contribution, we publish collectively here.
Here's what I've written (so far):
Baeldung on Scala
- All
- Scala Basics (33)
- Scala Collections (29)
- Functional Programming (18)
- Libraries (13)
- Scala Type System (12)
- Scala OOP (12)
- Scala Core (11)
- Akka (11)
- Scala Strings (10)
- Play Framework (7)
- Build Tools (7)
- Scala Web (4)
- Scala Syntax (4)
- Testing (3)
- Series (3)
- Scala Pattern Matching (3)
- Scala IO (3)
- Scala Exceptions (3)
- Scala Dates (3)
- Scala Concurrency (3)
- Persistence (2)
- Apache Spark (2)
How to Start and Quit a Scala REPL Session
Filed under Scala Basics
Learn how to start and quit a Scala REPL session.
Introduction to Macros in Scala 3
Filed under Scala Core
This article will provide an introduction to Macros in Scala 3
How to Convert a Character to Its ASCII Value in Scala
Filed under Scala Basics
Learn how to convert a character to ASCII value using Scala.
Safer Scala Code by Using WartRemover
Filed under Build Tools, Libraries
Learn how to write safer scala code by using WartRemover.
The Builder Pattern in Scala
Filed under Scala Basics
A quick and practical guide to the builder pattern in Scala.
Check if a List Is a Sublist of Another List
Filed under Scala Collections
A quick and practical guide to checking if a list is another list’s sublist.
Testing an Akka HTTP Application
Learn how to test an Akka HTTP Application.
Rotating a Scala Collection
Filed under Scala Collections
A quick and practical guide to rotating a Scala collection.
Introduction to ScalaPy
Filed under Libraries
Learn how to use Python from within Scala with ScalaPy.
AWScala – AWS SDK for Scala
Filed under Libraries
Learn about AWScala – the AWS SDK for Scala.
Scala Functional Programming Tutorial
Filed under Functional Programming, Series
Scala brings a lot of functional programming concepts into the JVM. Functional programming helps to improve the software quality by making it easier to test, reuse, and reason about.
Convert Byte Array to String in Scala
Filed under Scala Basics, Scala Strings
A quick and practical guide to converting byte array to string in Scala.
Using the “with” Keyword When Creating Instances
Filed under Scala Basics
A quick and practical guide to the “with” keyword.
Making Integration Testing Easier With TestContainers-scala
Filed under Testing
Learn how to create integration tests using Testcontainers-scala, a Scala wrapper around Testcontainers-java.
Introduction to Event Sourcing Using Akka Persistence
Filed under Akka
An introduction to Event Sourcing Using Akka Persistence.
Apache Pulsar Scala Client – pulsar4s
Filed under Libraries
Learn how to use the pulsar4s Scala Client for Apache Pulsar
Find the Last Occurrence of an Element in a List
Filed under Scala Collections
A quick and practical example of how to find the last occurrence of an element in a list in Scala.
Introduction to Macros in Scala 2
Filed under Scala Core
Learn how Macros work with Scala 2
Convert a String to Camel Case in Scala
Filed under Scala Strings
A quick and practical guide to converting Strings to camel case in Scala.
Scala Basics Tutorial
Filed under Series
This series takes the readers through the basics of the Scala language. The readers will be able to get started with their first Scala program with the help of the articles in this series.
Introduction to scala-async
Filed under Scala Concurrency
Learn about scala-async and how to use its async() and await() constructs.
How to Flatten Collections in Scala
Filed under Scala Collections
A quick and practical guide to flattening Scala collections.
How to Execute OS Commands in Scala Using os-lib
Filed under Scala IO
Learn about the os-lib library, which helps us manage files and processes in Scala.
Merge Two Maps in Scala
Filed under Scala Collections
Learn how to merge two maps in Scala.
Guide to Scala ListMap
Filed under Scala Collections
Introduction to Scala’s ListMap data type.
Scala Collections
Filed under Scala Collections, Series
A set of introductory and advanced articles about Scala Collections and its various methods.
Introduction to Apache Log4j in Scala
Filed under Libraries
A quick and practical guide to Log4j with Scala.
Match Types in Scala 3
Filed under Scala Pattern Matching, Scala Type System
Learn about match types in Scala 3 are and how we can use them to implement dependent methods.
Introduction to Akka gRPC
Filed under Akka
A quick and practical guide to Akka gRPC
Using forall in Scala
Filed under Scala Collections
Discover how to use forall in Scala
Guide to Scala ListSet
Filed under Scala Collections
Get a better understanding of ListSet in Scala
Server Sent Events With Alpakka
Filed under Akka
A guide to Server-Sent-Events with Alpakka.
Split a Sequence in Scala
Filed under Scala Collections
How to split a sequence using the partition, span, or groupBy functions.
Split List by Fixed Number of Elements
Filed under Scala Collections
A quick and practical guide to splitting a List by fixed number of elements.
Introduction to Scala.js
Filed under Scala Web
Learn how to create a front-end application in Scala using the Scala.js plugin.
A Guide to the Scala Retry Library
Filed under Libraries
A quick and practical introduction to the Scala retry library.
Scala Interview Questions
Filed under Scala Basics
Explore some of the basic Scala questions that could come up in a technical interview for Scala developers.
Array vs. WrappedArray in Scala
Filed under Scala Collections
Learn the difference between Array, ArraySeq, ArrayOps, and WrappedArray in Scala
Main Features of the Scala Language
Filed under Scala Basics
Learn the main features of the Scala language.
Count All Occurrences of a char Within a String in Scala
Filed under Scala Strings
Learn how to count all occurrences of a given char in a String in Scala.
Map Both Keys and Values of a Scala Map
Filed under Scala Collections
Learn to map both keys and values of a Scala Map.
Create an Empty Array in Scala
Filed under Scala Collections
Different ways of creating an empty array in Scala.
Initializing an Array in Scala
Filed under Scala Collections
Learn multiple approaches for initializing an array in Scala.
Guide to Arrays in Scala
Filed under Scala Collections
Lear about arrays in Scala.
Copy an Array to Another in Scala
Filed under Scala Collections
Learn various approaches for copying the elements of an array into another in Scala.
The Magnet Pattern in Scala
Filed under Functional Programming
A quick and practical guide to the Magnet pattern in Scala.
Remove Duplicates in a Scala List
Filed under Scala Collections
Learn to remove duplicate items from a List in Scala.
Get a List Item by Index in Scala
Filed under Scala Collections
Learn various ways of accessing the items of a List in Scala.
String Comparison in Scala
Filed under Scala Strings
Learn various approaches for comparing Strings in Scala.
Excluding Dependencies with SBT
Filed under Build Tools
Learn how to exclude transitive dependencies when building a Scala project with SBT.
Introduction to http4s
Filed under Scala Web
Learn how to create a simple HTTP server and client using http4s.
Convert RDD to DataFrame in Spark
Filed under Apache Spark
A quick and practical guide to converting RDD to DataFrame in Spark.
Function Composition in Scala
Filed under Functional Programming
Learn about function composition in Scala.
Convert a String to Date in Scala
Filed under Scala Strings
A quick and practical String and Date conversion guide in Scala.
map vs. flatMap in Apache Spark
Filed under Apache Spark
Learn the difference between Apache Spark’s map and flatMap functions in Scala.
Reading an Akka-HTTP Response Body as a String
Filed under Akka
Learn how to read an Akka HTTP Response body as a String.
Type Inference in Scala
Filed under Scala Type System
Learn about type inference in Scala with examples.
Different Ways to Stop Akka Actors
Filed under Akka
Learn different ways to stop an actor in Akka.
Guide to elastic4s – Elasticsearch Scala Client
Filed under Libraries
Learn how to use elastic4s to work with Elasticsearch in Scala applications.
Better Enumerations in Scala Using Enumeratum
Filed under Libraries
Learn about the Enumeratum library in creating improved Enumerations.
Iterating Over a Scala Map
Filed under Scala Collections
A quick and practical guide to iterating over a Map in Scala.
Simple REST Requests Using Requests-Scala
Filed under Scala Web
Learn to make simple RESTful requests with Requests-Scala.
Lambda Expressions in Scala
Filed under Functional Programming
Learn about lambda expressions in Scala.
Creating a List in Scala
Filed under Scala Collections
Learn different ways to create and populate Lists in Scala.
New Control and Quiet Syntax in Scala 3
Filed under Scala Basics
A quick and practical guide to Scala 3’s “quiet syntax”.
@inline and @noinline in Scala
Filed under Scala Basics
Learn about the @inline and @noinline annotations in Scala.
File Operations Using Ammonite-Ops
Filed under Scala IO
A look at Ammonite-Ops and how to use it to perform everyday file operations.
The inline Modifier in Scala 3
Filed under Scala Core
Learn about the inline modifier in Scala 3.
Ammonite Scripting
Filed under Libraries
Learn about Ammonite scripting with Scala.
Contextual Abstractions: Given Instances and Using Clauses
Filed under Scala Core
A quick and practical guide to Given and Using in Scala.
Extension Methods in Scala 3
Filed under Scala Core
Learn how we can define extension methods in different ways
Open Classes in Scala 3
Filed under Scala OOP
Learn about open classes in Scala 3.
Intersection Types in Scala 3
Filed under Scala Type System
Learn how to use intersection types in Scala 3.
Multiversal Equality in Scala 3
Filed under Scala Type System
Learn about the multiversal equality featured introduced in Scala 3.
Main Methods in Scala 3
Filed under Scala Basics
Learn about main methods in Scala 3.
Discovering Actors in Akka
Filed under Akka
Learn to discover Actors in Akka.
ScalaCache: A Caching Library To Rule Them All
Filed under Libraries
An overview of the ScalaCache library
Asynchronous and Reactive Programming With Monix in Scala
Filed under Functional Programming
A quick and practical introduction to Monix.
Guide to Scala Duration and FiniteDuration
Filed under Scala Dates
A quick and practical guide to Duration and FiniteDuration in Scala.
Scala 3 Implicit Redesign
Filed under Scala Core
Learn about the implicit redesign in Scala 3.
List Concatenation Operators in Scala
Filed under Scala Collections
Learn about List concatenation operators in Scala.
Parsing JSON with Circe
Filed under Libraries
Learn to parse JSON with Circe.
Working With Dates and Times in Scala
Filed under Scala Dates
A quick and practical guide to working with date and time in Scala.
Environment Setup and Artifacts Fetching Using Coursier
Filed under Build Tools
Learn to set up a development environment for Scala using Coursier.
Rich Wrappers in Scala
Filed under Scala Basics
A quick and practical introduction to rich wrappers in Scala.
StringBuilder in Scala
Filed under Scala Strings
In this tutorial, we’ll see why and how to use the StringBuilder class in Scala.
Benefits of Using Vector in Scala
Filed under Scala Collections
A quick and practical overview of Vector’s benefits in Scala.
Opaque Type Alias in Scala 3
Filed under Scala Type System
Learn about opaque type aliases in Scala 3.
Templating in Play Framework with Scala
Filed under Play Framework
A quick and practical overview of Play templating.
Creating Singletons in Scala
Filed under Scala OOP
Learn to create singletons in Scala.
@switch Annotation in Scala
Filed under Scala Pattern Matching
A quick and practical introduction to the @switch annotation in Scala.
Scala Traits vs. Abstract Classes
Filed under Scala OOP
In this tutorial, we’ll see what abstract classes and traits are in Scala and the key differences between them.
Introduction to Reactive Mongo
Filed under Persistence
Learn to perform queries with ReactiveMongo.
Implicit Imports in Scala
Filed under Scala Basics
Learn about implicit imports in Scala and go into more detail about the Predef package
Iteration With Index and Value in Scala
Filed under Scala Collections
In this tutorial, we’ll see how we can iterate through a collection while accessing the index in Scala.
Scheduling Asynchronous Tasks in Play Framework
Filed under Akka, Play Framework
Learn to schedule asynchronous tasks in Play Framework.
Introduction to Functional Programming in Scala
Filed under Functional Programming
Learn the basics of functional programming support in Scala.
Difference Between assert and require in Scala
Filed under Scala Basics
Learn about the functionalities of assert and require and their differences in semantics and exception behavior.
Introduction to Generic Programming in Scala with shapeless
Filed under Functional Programming
A quick and practical introduction to generic programming in Scala using the shapeless library
Error Handling in the Play Framework Using Scala
Filed under Play Framework
Learn to handle errors in the Play Framework using Scala.
Joining a Collection of Strings in Scala
Filed under Scala Strings
In this tutorial, we’ll see how to create a single String from a collection of elements, and in particular, a collection of Strings.
Type Disjunction (Union Types) in Scala
Filed under Scala Type System
Learn how to represent Type Disjunction or Union Types in Scala.
Path-Dependent Types in Scala
Filed under Scala Type System
Learn about path-dependent types in Scala.
Scala – Introduction to Cats
Filed under Functional Programming, Libraries
Learn about the Scala Cats library.
Repeated Parameters in Scala
Filed under Scala Basics
In this tutorial, we’ll see how to use the repeated parameters feature in Scala.
Introduction to Alpakka
Filed under Akka
Learn about Alpakka in Scala.
Type Declaration in Scala
Filed under Scala Basics
A type alias is usually used to simplify declaration for complex types, such as parameterized types or function types. Explore examples and how they work.
Caching in Play Framework for Scala
Filed under Play Framework
Learn about Play’s caching API with Scala.
Stream vs Views vs Iterators in Scala
Filed under Scala Collections
Learn about Streams, Views, and Iterators in Scala and how they differ.
Difference Between Nil, Null, Nothing, Unit, and None in Scala
Filed under Scala Basics
A quick guide to Nil, Null, Nothing, Unit, and None in Scala.
Finding the Index of an Element in a List with Scala
Filed under Scala Collections
In this tutorial, we explore the ways to find the index element in a List in Scala.
Access Play Configuration in Scala
Filed under Play Framework
Learn to access Play configurations in Scala.
How to Read Environment Variables in Scala
Filed under Scala Basics
A quick and practical guide to reading environment variables in Scala.
Guide to Scaladoc
Filed under Scala Basics
In this tutorial, we’ll learn how to add Scaladoc to code for a Scala project.
Implicit Parameters in Scala
Filed under Scala Core
Learn about implicit parameters in Scala.
Try-With-Resources in Scala
Filed under Scala Exceptions
A quick and practical guide to achieving try-with-resources semantics in Scala.
Conversion to and from a String in Scala
Filed under Scala Strings
Learn how to convert Scala data types to and from a String.
Sealed Keyword in Scala
Filed under Scala OOP
A quick and practical guide to the “sealed” keyword.
Lifting in Scala
Filed under Functional Programming
Learn ‘lifting’ in Scala in different scenarios.
The Option Type in Scala
Filed under Scala Basics
Learn about the Option type in Scala.
Introduction to Akka Scheduler
Filed under Akka
A quick and practical guide to Akka Scheduler.
Synchronous Handling of Futures
Filed under Scala Concurrency
Learn how to synchronously handle Futures in Scala.
The Difference Between foldLeft and reduceLeft in Scala
Filed under Scala Collections
Learn about foldLeft and reduceLeft in Scala.
Preserving Type Information at Runtime in Scala
Filed under Scala Core
Learn to preserve type information at runtime in Scala.
Building a REST API in Scala with Play Framework
Filed under Play Framework
We build an example Scala REST API back end using The Play Framework. We cover the routes file and how to build simple controller functionality.
Type Hierarchies in Scala
Filed under Scala Basics
Learn about Scala’s type hierarchy
Introduction to Slick
Filed under Persistence
Learn how to use Slick.
How to Convert Binary to Text Data in Scala
Filed under Scala Basics
Learn how to convert binary input streams into text using Scala.
Companion Objects in Scala
Filed under Scala OOP
A quick and practical introduction to Companion Objects in Scala.
Polymorphism in Scala
Filed under Scala OOP
A quick and practical overview of polymorphism in Scala.
Guide to Data Types in Scala
Filed under Scala Basics
Learn about data types in Scala.
Creating a Fat JAR Using SBT
Filed under Build Tools
Learn how to create a Fat JAR Using SBT.
Monoids and Semigroups in Scala
Filed under Functional Programming
Learn about monoids and semigroups in Scala.
Pimp My Library Pattern in Scala
Filed under Scala Core
A quick and practical overview of the implementation of the Pimp My Library pattern in Scala.
Configuring Heap Size for SBT
Filed under Build Tools
Have a look at several ways to configure the JVM heap size for applications built with SBT.
Type Casts in Scala
Filed under Scala Basics
Learn about type casting in Scala.
Loops in Functional Scala
Filed under Functional Programming
A quick and practical overview of looping in Functional Programming.
Demystifying View and Context Bounds
Filed under Scala Type System
Learn how implicit parameters allow us to write flexible generic code with both View and Context Bounds patterns.
Access Modifiers in Scala
Filed under Scala OOP
Learn about access modifiers in Scala.
Set Up IntelliJ for Scala Development with SBT
Filed under Build Tools
Learn how to set up IntelliJ with SBT for Scala development
Higher-Kinded Types
Filed under Scala Type System
Learn about Higher-Kinded Types in Scala and how to use them.
Range in Scala
Filed under Scala Basics
Learn about the Range in Scala and some of the common methods that can be applied
Functions in Scala
Filed under Functional Programming
A quick and practical overview of various types of functions in Scala.
Introduction to Strings in Scala
Filed under Scala Strings
Learn about Strings in Scala.
Algebraic Data Types in Scala
Filed under Scala Type System
Explore algebraic data types in Scala
By-Value and By-Name Parameters in Scala
Filed under Scala Basics
Learn about by-value and by-name parameters in Scala.
Object Oriented Programming in Scala
Filed under Scala OOP
Learn the basics of OOP and how to apply them in Scala.
Error Handling in Scala
Filed under Scala Exceptions
Learn both the object-oriented and functional ways to handle errors in Scala
The Cake Pattern
Filed under Functional Programming
Learn about the Cake Pattern and how to implement it in Scala.
Difference Between % and %% Symbols in build.sbt
Filed under Build Tools
Learn the difference between the % and %% symbols in the build.sbt file.
BDD Testing with Scala
Filed under Testing
Learn about Behavior Driven Development (BDD) testing with Scala.
Building REST APIs in Scala with Finch
Filed under Scala Web
Learn how to build REST APIs using Finch and Finagle
Self-Type Annotation in Scala
Filed under Scala Core
Learn how and when to use the self-type annotation in Scala.
Usages of Underscore (_) in Scala
Filed under Scala Syntax
Explore different ways to use the Scala underscore.
A DSL for Writing “20 seconds” in Scala
Filed under Scala Basics
Learn how to implement A DSL for Writing “20 seconds” in Scala.
Named and Default Arguments in Scala
Filed under Scala Basics
Learn about named and default arguments in Scala and when to use them.
File IO in Scala
Filed under Scala IO
A quick and practical overview of File IO in Scala.
String Interpolation in Scala
Filed under Scala Strings
Explore different ways of using string interpolation in Scala.
Futures and Promises in Scala
Filed under Scala Concurrency
A quick and practical guide to Futures and Promises in Scala.
Introduction to Scala Operators
Filed under Scala Syntax
Learn about Scala operators.
Typed Akka: The Actor Model Done Right
Filed under Akka
In this tutorial learn about Typed Akka using Scala.
Classes and Objects in Scala
Filed under Scala OOP
Learn about Scala Classes and Objects.
Mutability in Scala
Filed under Scala Basics
Mastering immutability allows us to reduce bugs caused when objects pass between functions or threads. Here we compare mutable and immutable objects in Scala.
Introduction to the Play Framework in Scala
Filed under Play Framework
Learn about the Play Framework with Scala.
Introduction to Optics in Scala Using Monocle
Filed under Libraries
Learn how to use the well-known Scala optics library Monocle.
Class Composition with Mixins
Filed under Scala OOP
A quick and practical guide to mixins in Scala.
Equality in Scala
Filed under Scala Basics
Learn about equality in Scala.
Basics of Generics in Scala
Filed under Scala Type System
Generics allow us to maintain type safety while writing code that can be used with a variety of types. Here we explore generic classes and functions.
Difference Between Class and Case Class in Scala
Filed under Scala OOP
Learn how to use case classes as immutable data containers in Scala and how they differ from regular classes.
Functions and Methods in Scala
Filed under Functional Programming
A quick and practical guide to functions/methods in Scala.
Guide to Scala Collections
Filed under Scala Collections
Learn about the Scala’s collection library.
Scala Conditional Expressions
Filed under Scala Syntax
Learn about conditional expressions in Scala
Variances in Scala
Filed under Scala Type System
Learn about variances in Scala.
Guide to Scala Enumerations
Filed under Scala Basics
Learn how to create, retrieve, and extend Scala’s enumeration support.
Exception Handling in Scala
Filed under Scala Exceptions
Learn both functional and imperative ways to handle exceptions in Scala
An Introduction to Scala Extractor Objects
Filed under Scala Pattern Matching
A quick and practical guide to Scala extractor objects.
A Comprehensive Guide to For-Comprehension in Scala
Filed under Functional Programming
Take a deep dive into Scala’s for-comprehension construct
Introduction to Traits in Scala
Filed under Scala OOP
Learn how to create and extend Scala traits.
Guide to lazy val in Scala
Filed under Scala Basics
Learn how Scala implements its lazy val feature and some problems you may encounter when using it.
Partial Functions in Scala
Filed under Functional Programming
Learn about partial functions in Scala.
For Loops in Scala
Filed under Scala Syntax
Learn for loops from basic to advanced in Scala
A Guide to Sorting in Scala
Filed under Scala Basics
Explore different methods for sorting data in Scala.
A Guide to Scala Tuples
Filed under Scala Collections
Learn all about Scala Tuples.
Higher-Order Functions in Scala
Filed under Functional Programming
Learn how to use higher-order functions from the Scala standard library and how to write your own higher-order functions.
Tail Recursion in Scala
Filed under Functional Programming
Learn about the advantages of tail recursion in Scala
Regular Expressions in Scala
Filed under Scala Core
Learn how to match regular expressions in Scala using the Regex class from the Scala standard library.
Introduction to Scala
Filed under Scala Basics
Learn about the core features of the Scala programming language