How to Create Subarray in Java
Java example to create subarray from array. Learn to use Java 8 Arrays.copyOfRange() method along with converting the subarray to list object.
Java example to create subarray from array. Learn to use Java 8 Arrays.copyOfRange() method along with converting the subarray to list object.
Java examples to use DateTimeFormatter for formatting ZonedDateTime, LocalDateTime, LocalDate and LocalTime with inbuilt and custom patterns.
Java 8 examples to convert from LocalDate to java.sql.Date and vice versa.
Java examples to convert from LocalTime to java.sql.Time and vice versa.
Learn to convert from java.time.LocalDate to java.util.Date and vice-versa using the easy-to-understand Java examples. 1. Convert Date to LocalDate The Date.getTime() method returns the epoch milliseconds i.e. the number of milliseconds since January 1, 1970, 00:00:00 GMT. To get the LocalDate, we need to first set the zone offset information …
Java 8 example to convert Date to LocalDateTime. Also, learn to convert LocalDateTime to Date instance to use in legacy code.
Java 8 example to convert LocalDateTime to ZonedDateTime. Also, learn to convert ZonedDateTime to LocalDateTime instance with example.
Java examples to convert a date from one timezone to another timezone. We will see the examples using ZonedDateTime, Date and Calendar classes.
Java examples to add or substract days, months or years from java.util.Date and java.time.LocalDateTime classes.
Java example of formatting LocalDateTime instance to String using default formats in DateTimeFormatter class and format to custom patterns.
Learn to calculate execution time or elapsed time of program or some statements using System.nanoTime() or System.currentTimeMillis() methods.
In Java, timestamps should be represented with java.time.Instant from Java 8, and java.sql.Timestamp till Java 7. Learn to get current timestamp in java.
Learn to compare two given dates in Java to find out which date is earlier and which is later in the universal timeline. We will see date comparison examples using the following classes: 1. Date Comparison since Java 8 1.1. Core Classes The most used date classes in Java 8 …
Java supports three timezone constants for Eastern Standard Time i.e. “EST”, “America/New_York” and “EST5EDT”. Learn to convert date to EST in Java.
Learn to use Spring Batch to read records from CSV files and insert them into the database using JdbcBatchItemWriter in a Spring Boot application.
Learn to use ItemStream and ChunkListener to count number of records processed by Spring batch job and log the record count in logs file or console.
Learn to use Spring batch ItemProcessor to add business logic after reading the input and before passing it to the writer for writing to the file/database.
In Spring batch processing, we can use a custom Tasklet or JobExecutionListener for deleting the input files, database rows, or other resources.
Learn to write CSV data using FlatFileItemWriter in a Spring batch application with an example that writes data to a flat file or stream.
Learn to read multiple flat files or CSV files from the filesystem or resources folder using Spring batch MultiResourceItemReader class.
Learn to configure Spring Batch FlatFileItemReader reader bean and read data from flat files such as a CSV file in a Spring Batch application.
Learn to create and configure Spring batch’s listeners for capturing the important events using JobExecutionListener, StepExecutionListener, ItemReadListener, ItemProcessListener, ItemWriteListener and SkipListener.
Learn to inject the Spring ApplicationContext beans into Quartz JobBean instance so we can get or set the quartz properties in the runtime.
Learn to configure Quartz scheduler and trigger to run Spring batch jobs configured using Spring boot Java configuration with example.
In enterprise applications, you will need to execute spring batch jobs periodically on fixed schedule using some cron expression passed to Spring TaskScheduler. In this example, we will execute our example spring batch job using spring’s inbuilt scheduling capability.
Learn to create a Spring batch job with Java configuration in a Spring boot application. The example reads a CSV and saves it to the database.
TypeScript supports callback functions to make your program asynchronous. A callback function is a function which is scheduled to be called after some asynchronous processing is completed.
In TypeScript, function overloading, or method overloading, is the ability to create multiple methods with the same name and a different number of parameters or types.
Learn to create functions in typescript and function type declaration. We will also see how to declare and pass optional parameters, setting default value for any parameter; and rest parameters with easy-to-follow examples. Table of Contents 1. Creating a function 2. Function Types 3. Optional Parameters 4. Parameters with Default …
A typescript template string (or template literal) is a regular JavaScript string which is enclosed within the back-tick characters (`) seeded with multiple placeholders denoted with ${ }. At runtime, the code replaces the placeholders with their real values. The process of evaluating a template literal containing one or more …
Set is a new data structure introduced in ES6. It allows to store distinct values into a List. Learn to create set, add and iterate set values.
Map is a new data structure introduced in ES6, to store key-value pairs. Learn to create map, add, delete, retrieve and iterate over Map entries.
In TypeScript, You can iterate over iterable objects (including array, map, set, string, arguments object and so on) using for…of loop. To be an iterable, an object must implement the @@iterator method.
TypeScript compiler uses tsconfig.json to get configuration options for generating JavaScript code from TypeScript sourcecode. When you uses $ tsc command to compile TypeScript code, compiler searches for configurations loaded in tsconfig.json.
In TypeScript, string literals allow you to specify the exact value a string must have in it’s lifespan. You can assume it a form as ‘string based enum’ which also is named group of string constants.
In TypeScript, enums are set of named constants. Though it is optional, but enums should be a named group of related constants. TypeScript supports both traditional enums and string-based enums.
Learn to create an array, add/remove items, and iterate over array items along with cloning and merging the arrays in TypeScript.
In JavaScript, a variable is said to be “undefined” if it has been declared but not initialized. Whereas “null” is assigned to a variable whose value is absent at the time of initialization. In simple words, when we do not assign any value to a variable, the JavaScript engine treats …
In TypeScript, a union type variable is a variable which can store multiple type of values (i.e. number, string etc). A union type allows us to define a variable with multiple types. The union type variables are defined using the pipe (‘|’) symbol between the types. The union types help …
In TypeScript (or JavaScript), we can compare the two variables with either equality operator (‘==’) or strict equality operator (‘===’). Both comparison operators seems almost similar; but the way, they compare two given variables, is very different. The equality operator compares only the value after applying the type coercion, if …
The spread operator is a new addition to the features available in the JavaScript ES6 version. The spread operator is used to expand or spread an iterable or an array in Typescript or Javascript. 1. When to use the Spread Operator? The spread operator (in the form of ellipsis) can …
TypeScript logical operators are similar to what we have learned in JavaScript logical operators. These operators help in comparing boolean expressions and producing a single boolean value as result. 1. Logical Operators Operator Description Logical AND operator – && If both operands (or expressions) are true, then result will be …
TypeScript comparison operators are the same as JavaScript. Comparison operators help in comparing two variables by their values. Please note that some operators use type coercion while comparing the values, while some do not. Please use them carefully. Type coercion means that when the operands of an operator are different …
TypeScript supports type checking for all primitive types and object types. TypeScript also supports generics, decorators, and ES6 module types as well. It is important to learn that the type system in typescript is designed to be optional. So all programs written in JavaScript are TypeScript programs as well. Table …
In this TypeScript tutorial, learn to basics, compiler, installation and how to start development in TypeScript language with examples.
An operator is a symbol that represents a specific action. An arithmetic operator can be used with one or more than values to produce a single value. In typescript, we can perform arithmetic operations using below given 10 operators. Arithmetic operators Operator Name Description and Example x + y Addition …
In vanilla JavaScript, variables are declared using ‘var‘ keyword. In version ES6, we can define the variables using let and const keywords too. All three keywords have similar syntax for variable declaration and initialization, but they differ in their scope and usage. 1. Differences between var, let and const We …
Variable hoisting in JavaScript means to move all variable declarations to top of function. This means that if we declare a variable at the end of a function, the runtime will hoist it to the top and we will not have any error if we would have used that variable …
In JavaScript, Truthy expressions evaluate to boolean true value and Falsy expressions evaluate to boolean false value. Unlike other programming languages, truthy and falsy values are not limited to boolean data types and comparisons. They can have many other forms. Let us learn what makes an expression truthy or falsy …
Transpilers, or source-to-source compilers, are tools that read the sourcecode written in one programming language and produce the equivalent code in another programming language with a similar level of abstraction. A good example of transpiler is the Typescript transpiler which converts Typescript code to JavaScript. Similarily, Babel transpiler can also …
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.