Convert between Date to LocalDateTime
Java 8 example to convert Date to LocalDateTime. Also, learn to convert LocalDateTime to Date instance to use in legacy code.
“Core Java” is Sun’s term, used to refer to Java SE, the standard edition and a set of related technologies, like the Java VM, CORBA, etc. This is mostly to differentiate from others like Java ME or Java EE. “Core Java” is Oracle’s definition and refers to subset of Java SE technologies.
The Core Java technologies and application programming interfaces (APIs) are the foundation of the Java Platform, Standard Edition (Java SE). They are used in all classes of Java programming, from desktop applications to Java EE applications.
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 create a Java List with only one element in it using Arrays.asList() and Collections.singletonList() methods.
Learn to append the data to a file in Java using Standard IO’s BufferedWritter, PrintWriter, FileOutputStream and NIO Files classes.
Learn to write text and binary data into files using Java Writer, FileChannel, ByteBuffer, Files.write() and writeString() methods in Java 8 and Java 11.
Inside a Java program, we can write a special text that will be ignored by the Java compiler — known as the comment. Comments allow us to exclude code from the compilation process (disable it) or clarify a piece of code to yourself or other developers. Learn everything about Java comments, …
In traditional programming languages, such as Java, a variable is a placeholder for storing a value of a particular type: a string, a number, or something else. This Java tutorial discusses what a variable is and the types of variables. Also, look at the example of how to declare a variable in Java. We …
JDK, JRE and JVM is very common words when developers talk about java applications and their development environments. Let’s find out the differeneces between these words.
SSLHandshakeException appear in logs when there is some error occur while validating the certificate installed in client machine with certificate on server machine. In this post, we will learn about fixing this if you are using Apache HttpClient library to create HttpClient to connect to SSL/TLS secured URLs.
Simple and easy-to-understand examples of sorting a HashMap by values, using Java 8 Stream, in ascending and descending (reverse) orders.
Simple and easy-to-understand examples to sort a Map by key, using TreeMap and Java 8 Stream, in ascending and descending (reverse) orders.
In java garbage collection tutorial, we will learn about object life cycle, difference between mark-sweep, mark-sweep-compact and mark-copy mechanisms, different single threaded and concurrent GC algorithms (e.g. G1), and various flags to control the gc algorithm’s behavior and log useful information for applications.
Learn to resolve the InputMismatchException by reading the typesafe user inputs from the console in any interactive java application.
In this Java AIML tutorial, we will learn to create demo chatbot application using AIML and NLP application program-ab hosted on google-code repository.
My requirement was to read the HTTP request body 2 times in servlet filter and the pass the request to filter chain. HttpServletRequestWrapper helped me.
Learn to install a Docker on Windows, create a Docker image for Spring Boot application and deploy the Dockerized image in the developer machine.
Dozer bean mapping example. Learn dozer for mapping nested object, use Spring bean mapping builder, dozer custom converters to copy data between beans.
Static keyword in java can be applied on variables, methods, blocks, import and inner classes. Learn the effect of using static keyword in detail.
Java constructors are special method-like constructs that allow fully initializing the object state before other classes can use it.
Java Inheritance refers to the ability of a child class to inherit all the non-private properties and methods from the parent class.
JSON.simple is lightweight JSON processing library which can be used to read JSON, write JSON file. Produced JSON will be in full compliance with JSON specification (RFC4627).
JDOM parser can be used to read XML, parse xml and write XML file after updating content of it. It stores JDOM2 document in memory to read xml values.
Learn to read a text file into String using Files.readAllBytes(), Files.lines() and BufferedReader classes in various ways.
Java example to use regular expressions to search and replace unwanted and non-printable characters ASCII characters from text file content.
Learn to convert byte[] to String and String to byte[] in java – with examples. Conversion between byte array and string may be used in many cases including IO operations, generate secure hashes etc.
learned to parse a string (decimal, octal and hexadecimal) to int or Integer types using Integer.parseInt(), valueOf() and decode() methods.
In this guide to Java enum with string values, learn to create enum using strings, iterate over all enum values, get enum value and to perform reverse lookup to find enum by string parameter.
Learn to split string by comma or space and store in array or arraylist. Use given Java program to convert string to List in Java.
We may need custom serialization in java in many cases. For example, we have legacy java classes that we are not willing to modify for any reason. There can be some design constraints as well. Or even simply, the class is expected to be changed in future releases which could …
RxJava 2.0 is open source extension to java for asynchronous programming by NetFlix. It is much closer to functional programming as seen in java 8 lambda expressions. The basic building blocks of reactive code are Observables and Subscribers. An Observable emits items; a Subscriber consumes those items.
Learn to convert XMLGregorianCalendar to Date class or string value. Also learn to apply timezone changes and daylight saving effects as well.
To triage SSL issues, enable SSL debug logging by passing javax.net.debug=ssl runtime argument to your server/program.
In fizz buzz game, we say numbers such that if that number is a multiple of five, we say “fizz”, if multiple of seven, we say “buzz”, multiple of both, we say “fizzbuzz.”
Learn the difference between association, aggregation and composition in Java with source code, examples and real-life usecases.
Learn to use Java CORS filter. CORS is a mechanism that allows JavaScript on a web page to make AJAX requests to another domain.
Learn to format XMLGregorianCalendar instance to string in multiple patterns e.g. ‘MM/dd/yyyy hh:mm a z’ using DateTimeFormatter and SimpleDateFormat classes in Java.
To disable or bypass SSL Certificate checking is never a recommended solution for SSL issues, but at test environment – sometimes you may need this.
In java example, we will learn xpath namespace resolution into an XML file using NamespaceContext which has namespace declarations and their usages.
Learn to convert OutputStream to InputStream in Java using ByteArrayInputStream and Java NIO Files Channel API.
Learn to read CSV file in Java and write data to CSV files. Super CSV file is opensource library to support read and write operations on CSV files.
In this Java puzzle, we have a series of numbers and exactly one number is missing. We have to write a program to find the missing number.
Learn about Localization and Internationalization with Locale. Learn to create Locale objects and use them for formatting dates and messages.
Java examples of unzipping and extracting the zip file using java.util.zip package and apache commons compress module.
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.