How do I split large excel file into multiple smaller files?

A friend of mine told me that he has a large Excel file, and he asked me if I could split the file into multiple smaller Excel files. So I write this little program using Apache POI to do it.

The code snippet below basically contains the following steps:

  1. Load the Excel as an InputStream from the classpath, if the file was not found the program will exit.
  2. Create XSSFWorkbook from the input stream, and get the first XSSFSheet from the workbook.
  3. Iterate the rows of data from the source worksheet.
  4. On the first rownum for each split file we create a new workbook using SXSSFWorkbook and also create the SXSSFSheet.
  5. Read the first row from the source worksheet, store it in headerRow to be used for creating header row in each new sheet.
  6. If we are at the first row, write the header.
  7. Write each row from the source sheet to the destination sheet untuk the max rows is reached.
  8. Write the workbook into a new file.

And here is the complete code that you can try.

package org.kodejava.poi;

import org.apache.poi.xssf.streaming.SXSSFCell;
import org.apache.poi.xssf.streaming.SXSSFRow;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

public class SplitExcelDemo {
    public static final int MAX_ROWS_PER_FILE = 1000 - 1;
    public static final boolean WITH_HEADER = true;

    public static void main(String[] args) {
        LocalDateTime startTime =;
        String filename = "/stock.xlsx";
        try (InputStream is = SplitExcelDemo.class.getResourceAsStream(filename)) {
            if (is == null) {
                System.out.println("Source file was not found!");

            XSSFWorkbook srcWorkbook = new XSSFWorkbook(is);
            XSSFSheet srcSheet = srcWorkbook.getSheetAt(0);
            int physicalNumberOfRows = srcSheet.getPhysicalNumberOfRows();

            int rownum = 0;
            int splitCounter = 0;

            SXSSFWorkbook destWorkbook = null;
            SXSSFSheet destSheet = null;

            XSSFRow headerRow = null;

            for (Row srcRow : srcSheet) {
                if (rownum == 0) {
                    // At the beginning let's create a new workbook and worksheet
                    destWorkbook = new SXSSFWorkbook();
                    destSheet = destWorkbook.createSheet();

                if (srcRow.getRowNum() == 0 && WITH_HEADER) {
                    // Copy header row to be use in each split file
                    headerRow = (XSSFRow) srcRow;

                if (rownum == 0 && WITH_HEADER) {
                    // Add row header to each split file
                    if (headerRow != null) {
                        SXSSFRow firstRow = destSheet.createRow(rownum);
                        int index = 0;
                        for (Cell cell : headerRow) {
                            SXSSFCell headerCell = firstRow.createCell(index++, cell.getCellType());
                            if (cell.getCellType() == CellType.STRING) {
                } else {
                    // Copy rows from source worksheet into destination worksheet
                    SXSSFRow descRow = destSheet.createRow(rownum);
                    int index = 0;
                    for (Cell cell : srcRow) {
                        SXSSFCell destCell = descRow.createCell(index++, cell.getCellType());
                        switch (cell.getCellType()) {
                            case NUMERIC -> destCell.setCellValue(cell.getNumericCellValue());
                            case STRING -> destCell.setCellValue(cell.getStringCellValue());

                // When a max number of rows copied are reached, or when we are at the end of worksheet, 
                // write data into a new file 
                if (rownum == MAX_ROWS_PER_FILE || srcRow.getRowNum() == physicalNumberOfRows - 1) {
                    rownum = -1;
                    String output = String.format("split-%03d.xlsx", splitCounter++);
                    System.out.println("Writing " + output);
                    try (OutputStream os = new FileOutputStream(output)) {
                    } catch (IOException e){

                rownum = rownum + 1;

            // Display processing time
            LocalDateTime endTime =;
            long minutes = startTime.until(endTime, ChronoUnit.MINUTES);
            startTime = startTime.plusMinutes(minutes);
            long seconds = startTime.until(endTime, ChronoUnit.SECONDS);
            System.out.printf("Splitting finished in %d minutes and %d seconds %n", minutes, seconds);
        } catch (Exception e) {

Maven Dependencies


Maven Central Maven Central

The output of running this program will look like this:

Writing split-000.xlsx
Writing split-001.xlsx
Writing split-002.xlsx
Writing split-003.xlsx
Writing split-004.xlsx
Writing split-005.xlsx
Writing split-006.xlsx
Writing split-007.xlsx
Writing split-008.xlsx
Writing split-009.xlsx
Splitting finished in 0 minutes and 8 seconds 

How do I get the number of processors available to the JVM?

The Runtime.getRuntime().availableProcessors() method returns the maximum number of processors available to the Java virtual machine, the value will never be smaller than one. Knowing the number of available processor you can use it for example to limit the number of thread in your application when you are writing a multi-thread code.

package org.kodejava.lang;

public class NumberProcessorExample {
    public static void main(String[] args) {
        final int processors = Runtime.getRuntime().availableProcessors();
        System.out.println("Number of processors = " + processors);

Running the code snippet give you something like:

Number of processors = 8

How do I show Spring transaction in log / console?

When you use the Spring framework @Transactional annotation in your service layer you might want to see what is happening in your code related to database transaction. You want to see when a transaction is started, when it is committed or rollbacked.

To activate the log for transactional message you can add the following configurations in your application properties file. For example when using the JpaTransactionManager you can set the log level to DEBUG.


Running the spring boot application with these configuration, the JpaTransactionManager will write something line these on your log file or console:

2023-03-29T23:06:52.194+08:00 DEBUG 54056 --- [nio-9090-exec-3] o.s.orm.jpa.JpaTransactionManager        : Creating new transaction with name [org.kodejava.webapp.accounting.service.impl.CalculationServiceImpl.recalculate]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2023-03-29T23:06:52.194+08:00 DEBUG 54056 --- [nio-9090-exec-3] o.s.orm.jpa.JpaTransactionManager        : Opened new EntityManager [SessionImpl(974784570<open>)] for JPA transaction
2023-03-29T23:06:52.195+08:00 DEBUG 54056 --- [nio-9090-exec-3] o.s.orm.jpa.JpaTransactionManager        : Exposing JPA transaction as JDBC [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@4150907e]
2023-03-29T23:06:52.195+08:00 DEBUG 54056 --- [nio-9090-exec-3] o.s.orm.jpa.JpaTransactionManager        : Found thread-bound EntityManager [SessionImpl(974784570<open>)] for JPA transaction
2023-03-29T23:06:52.195+08:00 DEBUG 54056 --- [nio-9090-exec-3] o.s.orm.jpa.JpaTransactionManager        : Participating in existing transaction
2023-03-29T23:06:52.237+08:00 DEBUG 54056 --- [nio-9090-exec-3] o.s.orm.jpa.JpaTransactionManager        : Initiating transaction commit
2023-03-29T23:06:52.237+08:00 DEBUG 54056 --- [nio-9090-exec-3] o.s.orm.jpa.JpaTransactionManager        : Committing JPA transaction on EntityManager [SessionImpl(974784570<open>)]
2023-03-29T23:06:52.237+08:00 DEBUG 54056 --- [nio-9090-exec-3] o.s.orm.jpa.JpaTransactionManager        : Closing JPA EntityManager [SessionImpl(974784570<open>)] after transaction

How do I build simple search page using ZK and Spring Boot?

In this example we are going to build a simple search page using ZK framework and Spring Boot. We are going to use the latest available version of Spring Boot (3.0.0) and ZK Framework ( So without taking more time let’s start by creating a new spring boot project with the following pom.xml. You can create the initial project using your IDE or spring initializr.

Create a Spring Boot project and add the following dependencies:

  • zkspringboot-starter
  • zkplus
  • spring-boot-devtools
  • spring-boot-starter-data-jpa
  • mysql-connector-j
  • lombok

The pom.xml File

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""
        <relativePath/> <!-- lookup parent from repository -->





            <id>ZK CE</id>
            <name>ZK CE Repository</name>
            <id>ZK EVAL</id>
            <name>ZK Evaluation Repository</name>

</project> File

This properties file configure ZK application homepage and the prefix where the zul files are located. We also configure the datasource to our application database.


spring.datasource.password= Entity Definition

An entity that represent out record label with just two property of id and name. Getters and setters are generated by Lombok library, it also generated to equals() and hashcode() method, and also the toString() method.

package org.kodejava.zk.entity;

import jakarta.persistence.*;
import lombok.Data;

public class Label {
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String name;

The definition.

Create the LabelRepository which extends the JpaRepository and JpaSpecificationExecutor interfaces.

package org.kodejava.zk.repository;

import org.kodejava.zk.entity.Label;
import org.springframework.stereotype.Repository;

public interface LabelRepository extends JpaRepository<Label, Long>, JpaSpecificationExecutor<Label> {
} a base search controller.

A base class that we can use to implements all the search page in an application. Basically it provides the method to search our application data. It defines a couple of abstract method that need to be implemented by the search controller classes such as what repository to use and the specification for searching the data. We can also define the default sort column and the direction of the data sorting.

package org.kodejava.zk.controller;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zul.Listbox;

public abstract class AbstractSearchController<T> extends SelectorComposer<Component> {
    protected Listbox listbox;

    public abstract JpaSpecificationExecutor<T> getRepository();

    public abstract Specification<T> getSpecification();

    public abstract String getCacheKey();

    protected String getDefaultSortColumn() {
        return "id";

    protected Sort.Direction getDefaultSortDirection() {
        return Sort.Direction.ASC;

    protected boolean getMultiple() {
        return false;

    public void doAfterCompose(Component comp) throws Exception {

    public void search() {
        SearchListModel<T> model = new SearchListModel<>(getRepository(), getSpecification(), getCacheKey());

    public void onEnterPressed(Event event) {

    public int getPageSize() {
        return SearchListModel.PAGE_SIZE;

An implementation of ListModel, this class will query the database using the provided repository and specification. It read data page-by-page and cache it so when we navigating the Listbox page it doesn’t read the data that have already been cached.

package org.kodejava.zk.controller;

import org.zkoss.zk.ui.Execution;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zul.FieldComparator;
import org.zkoss.zul.ListModelList;

import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;

public class SearchListModel<T> extends ListModelList<T> {
    public static final int PAGE_SIZE = 5;
    private final JpaSpecificationExecutor<T> repository;
    private final String cacheKey;
    private long totalElements;

    private Comparator<T> comparator;
    private boolean ascending = false;
    private final Specification<T> specification;
    private Sort.Direction defaultSortDirection = Sort.Direction.ASC;
    private String defaultSortColumn = "id";

    public SearchListModel(JpaSpecificationExecutor<T> repository, Specification<T> specification, String cacheKey) {
        this.repository = repository;
        this.specification = specification;
        this.cacheKey = cacheKey;
        this.totalElements = repository.count(specification);

    public T getElementAt(int index) {
        Map<Integer, T> cache = getCache();

        T target = cache.get(index);
        if (target == null) {
            Sort sort =, getDefaultSortColumn());
            if (comparator != null) {
                FieldComparator fieldComparator = (FieldComparator) comparator;
                String orderBy = fieldComparator.getRawOrderBy();
                sort = ? Sort.Direction.ASC : Sort.Direction.DESC, orderBy);
            Page<T> pageResult = repository.findAll(specification, PageRequest.of(getPage(index), PAGE_SIZE, sort));
            totalElements = pageResult.getTotalElements();
            int indexKey = index;
            for (T t : pageResult.toList()) {
                cache.put(indexKey, t);
        } else {
            return target;

        target = cache.get(index);
        if (target == null) {
            throw new RuntimeException("element at " + index + " cannot be found in the database.");
        } else {
            return target;

    public int getSize() {
        return (int) totalElements;

    public void sort(Comparator<T> comparator, boolean ascending) {
        super.sort(comparator, ascending);
        this.comparator = comparator;
        this.ascending = ascending;

    private Map<Integer, T> getCache() {
        Execution execution = Executions.getCurrent();
        Map<Integer, T> cache = (Map<Integer, T>) execution.getAttribute(cacheKey);
        if (cache == null) {
            cache = new HashMap<>();
            execution.setAttribute(cacheKey, cache);
        return cache;

    private int getPage(int index) {
        if (index != 0) {
            return index / PAGE_SIZE;
        return index;

    public Sort.Direction getDefaultSortDirection() {
        return defaultSortDirection;

    public void setDefaultSortDirection(Sort.Direction defaultSortDirection) {
        this.defaultSortDirection = defaultSortDirection;

    public String getDefaultSortColumn() {
        return defaultSortColumn;

    public void setDefaultSortColumn(String defaultSortColumn) {
        this.defaultSortColumn = defaultSortColumn;

Our label search page controller which extends from AbstractSearchController class. We provide the LabelRepository and the Specification to filter the data.

package org.kodejava.zk.controller;

import jakarta.persistence.criteria.Predicate;
import org.kodejava.zk.entity.Label;
import org.kodejava.zk.repository.LabelRepository;
import org.zkoss.zul.Textbox;

import java.util.ArrayList;
import java.util.List;

public class LabelSearchController extends AbstractSearchController<Label> {
    private LabelRepository labelRepository;

    private Textbox labelNameTextbox;

    public JpaSpecificationExecutor<Label> getRepository() {
        return labelRepository;

    public Specification<Label> getSpecification() {
        return (root, query, criteriaBuilder) -> {
            List<Predicate> predicates = new ArrayList<>();
            String labelName = labelNameTextbox.getValue();
            if (!labelName.isBlank()) {
                predicates.add("name"), "%" + labelName + "%"));
            return criteriaBuilder.and(predicates.toArray(new Predicate[0]));

    public String getCacheKey() {
        return "LABEL_CACHE_KEY";

label-search.zul – Label Search Page in ZUL

The search page with a label name Textfield to search by label name. The Listbox will display the data with pagination.

    <window id="labelSearchWin" zclass="none" border="none" visible="true"
            apply="org.kodejava.zk.controller.LabelSearchController" width="100%">

        <grid id="searchForm">
                <column width="200px"/>
                    <label value="Label Name"/>
                    <textbox id="labelNameTextbox" width="450px" maxlength="50"/>


            <button id="searchButton" label="Search"/>


            <listbox id="listbox" mold="paging" pageSize="${labelSearchWin$composer.pageSize}" visible="false">
                    <listheader label="No" hflex="min"/>
                    <listheader label="Label Name" sort="auto(name)"/>
                    <listheader label="Action" hflex="min"/>
                <template name="model">
                        <listcell label="${forEachStatus.index + 1}" hflex="min"/>
                        <listcell label="${}"/>
                        <listcell hflex="min">
                                <button label="Edit" forward="onClick=listbox.onEdit(${each})" tooltiptext="Edit Data"/>

Running the application and access it at localhost:8080 will give you a screen like the screenshot at the beginning of this post.

The complete source code can be found in the following GitHub repository kodejava-zk-search.

10 Best Career Options for Java Developers in 2023


The programming world is changing, and opportunities await aspiring coders. With robust support from major technology giants and an ever-expanding job market, now is the time to start your career as a Java developer.

Whether you’re a professional looking to break into the field or a beginner with no experience who wants to get a java developer job with no experience, we’ve rounded up ten exciting options that are sure to put you on your way to success. From mobile app development to software engineering, this article explores the best career options for you in 2023!

Will Java Developers Still Be in Demand in 2023?

If the ever-increasing number of job posts—specifically for Java developers at Jooble is anything to go by, Java developers will have no shortage of job offers in 2023. Also, as an open-source language, Java is widely used for enterprise development, mobile applications, web applications, and artificial intelligence projects.

In addition, its inventor – Oracle –has regularly added new features to the language over the last two decades. This has allowed Java developers to stay ahead of the curve when it comes to coding skills.

Moreover, as technology advances, more organizations are turning to Java developers to meet their needs. For example, many businesses are transitioning their entire infrastructure from monolithic services and adopting microservices architectures.

This trend requires skilled Java developers who understand how microservices work and can develop them effectively. The same goes for AI-driven systems that rely heavily on Java development expertise.

All things considered, it means there will still be plenty of demand for talented Java developers in 2023 and beyond. Here are ten of the best career options for Java developers in 2023:

1. DevOps Engineer

A DevOps Engineer is a software engineer who works collaboratively with development and operations teams. They ensure that digital projects are delivered quickly, efficiently, and without errors.

They are responsible for deploying software, maintaining application stability, and automating workflows. Essentially, they are the bridge between development and operations teams, ensuring communication flows within an organization.

Becoming a DevOps Engineer requires knowledge of programming languages like Java, and scripting languages like Ruby or Python. It also requires an understanding of automation tools like Jenkins or Chef; source code management platforms like Git, and cloud-based solutions such as Amazon Web Services or Microsoft Azure.

Becoming a DevOps Engineer could be a great choice for Java developers looking for the best career options in 2023. This is because there is an increasing demand for this role in organizations worldwide.

2. Artificial Intelligence Engineer

Artificial Intelligence (AI) is a rapidly growing field. As a result, companies are looking for developers with expertise in AI technologies to help them stay competitive.

AI Engineers are responsible for creating intelligent systems that can perform tasks independently and operate with human-like accuracy and speed. Becoming an AI Engineer requires knowledge of Java, Python, R programming language, Natural Language Processing (NLP), Machine Learning algorithms, and more. For Java developers in 2023, this could be a great option, as AI technologies will only increase in the coming years.

3. Solution Architect

A Solution Architect is a technical leader who designs and implements software solutions to solve business problems. They create high-level designs that integrate various systems, applications, and services, maximizing efficiency and scalability.

To become one, you’ll need to understand software engineering fundamentals such as object-oriented programming (OOP) and system design concepts like architecture patterns and frameworks. Additionally, you’ll need to be well-versed in the latest technologies and trends in the industry, such as Kubernetes and microservices.

To become a Solution Architect, the best approach is to start by gaining experience with coding; then pursue additional training focused on system architecture principles and design patterns. Having some relevant certifications will also give you an edge over other candidates applying for positions.

4. Data Scientist

Data Scientists manage, analyze, and interpret data to extract valuable insights. They use various technologies and methods such as big data analytics, machine learning algorithms, natural language processing (NLP), statistical analysis, etc.

Becoming a successful Data Scientist requires good knowledge of programming languages like Java along with strong mathematical and statistical skills. You’ll also need to be well-versed in databases, machine learning tools, data visualization frameworks, and modern algorithms such as deep learning neural networks. Data Scientists are in high demand these days due to organizations’ ever-increasing use of data-driven decisions.

5. Scrum Master

A Scrum Master is a role that is essential for software development teams that employ agile methodology. A Scrum Master is responsible for organizing and managing a team’s workflow during the phases of development.

They’re responsible for ensuring that tasks and deadlines are met. They also facilitate conversations around potential roadblocks or issues.

For Java developers looking to become a Scrum Master in 2023, it is essential to understand the fundamentals of agile software development, such as its core tenets and techniques, before attempting to take on the role. Being fluent with related frameworks, like Extreme Programming and Lean Development, can also be beneficial. It would also help to have good communication and interpersonal skills and knowledge of your team members’ strengths and weaknesses to manage their assigned tasks effectively.

6. Mobile Developer

Mobile Developers specialize in creating applications for mobile devices such as smartphones and tablets. They use coding languages like Java, HTML5, and CSS3 to create user interfaces and write code that interacts with an application’s backend systems.

In 2023, the demand for Mobile Developers is projected to increase exponentially. Mobile applications will become increasingly crucial for businesses as more organizations move their processes and services online.

To become a successful Mobile Developer in 2023, you’ll need to understand software development and mobile design basics. Additionally, understanding modern trends such as augmented reality (AR) can also be beneficial.

7. Project Manager

Project Managers are responsible for overseeing the development process from start to finish. They work closely with teams of software developers, UX/UI designers, marketers, and other professionals to ensure that each project is completed on time and within budget.

Project managers need strong communication skills and an understanding of software development processes. They should be familiar with popular project management tools like JIRA and Trello.

8. Database Administrator

Database Administrators are responsible for creating, maintaining, and securing databases. They use programming languages like Java to develop database applications.

In 2023, Database Administrators will need to be experts in a wide range of technologies such as SQL, NoSQL, OLTP/OLAP systems, and cloud computing platforms. Additionally, knowledge of related areas such as machine learning and big data can also be beneficial.

9. Security Analyst

Security Analysts are responsible for protecting networks and systems from cyber threats such as malware, viruses, and unauthorized access. They use programming languages like Java to develop security protocols, monitor networks for suspicious activities, investigate incidents and analyze system vulnerabilities.

To succeed in this role in 2023, Security Analysts need to understand cyber-security best practices thoroughly. They should also be knowledgeable about the latest threats and technologies, such as biometrics, artificial intelligence (AI), and blockchain.

10. Cloud Solutions Architect

Cloud Solutions Architects design and implement cloud-based systems for businesses. They need to understand the fundamentals of cloud computing, including infrastructure as a service (IaaS), platform as a service (PaaS), and software as a service (SaaS).

In 2023, Cloud Solutions Architects should have experience with popular cloud computing providers such as Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform. Additionally, they should know the principles of DevOps, microservices, and containerization.

In summation, these are the ten best career options for Java Developers in 2023. With a good understanding of software development principles and the latest technologies, you can pursue any of these roles and excel in them. Good luck!

How do I calculate days between two dates excluding weekends and holidays?

The code snippet below shows you a simple way to calculate days between two dates excluding weekends and holidays. As an example, you can use this function for calculating work days. The snippet utilize the java.time API and the Stream API to calculate the value.

What we do in the code below can be described as the following:

  • Create a list of holidays. The dates might be read from a database or a file.
  • Define filter Predicate for holidays.
  • Define filter Predicate for weekends.
  • These predicates will be use for filtering the days between two dates.
  • Define the startDate and the endDate to be calculated.
  • Using Stream.iterate() we iterate the dates, filter it based on the defined predicates.
  • Finally, we get the result as list.
  • The actual days between is the size of the list, workDays.size().
package org.kodejava.datetime;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.Month;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

public class DaysBetweenDates {
    public static void main(String[] args) {
        List<LocalDate> holidays = new ArrayList<>();
        holidays.add(LocalDate.of(2022, Month.DECEMBER, 26));
        holidays.add(LocalDate.of(2023, Month.JANUARY, 2));

        Predicate<LocalDate> isHoliday = holidays::contains;
        Predicate<LocalDate> isWeekend = date -> date.getDayOfWeek() == DayOfWeek.SATURDAY
                || date.getDayOfWeek() == DayOfWeek.SUNDAY;

        LocalDate startDate = LocalDate.of(2022, Month.DECEMBER, 23);
        LocalDate endDate = LocalDate.of(2023, Month.JANUARY, 3);
        System.out.println("Start date = " + startDate);
        System.out.println("End date   = " + endDate);

        // Days between startDate inclusive and endDate exclusive
        long daysBetween = ChronoUnit.DAYS.between(startDate, endDate);
        System.out.println("Days between = " + daysBetween);

        List<LocalDate> workDays = Stream.iterate(startDate, date -> date.plusDays(1))

        long actualDaysBetween = workDays.size();
        System.out.println("Actual days between = " + actualDaysBetween);

Running the code snippet above give us the following result:

Start date = 2022-12-23
End date   = 2023-01-03
Days between = 11
Actual days between = 5

How do I discover the quarter of a given date?

The following code snippet shows you a various way to get the quarter of a given date. Some methods that we use below are:

  • Using the new java.time API of Java 8 IsoFields.QUARTER_OF_YEAR.
  • Using Java 8 DateTimeFormatter pattern of Q or q. The length of “q” give us a different result.
  • Using java.util.Date.
  • Using java.util.Calendar.
  • Get the quarter from an array of string.

Let’s see the code snippet in action.

package org.kodejava.datetime;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.IsoFields;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class DateQuarter {
    public static void main(String[] args) {
        // Using Java 8
        LocalDate now =;
        int quarter = now.get(IsoFields.QUARTER_OF_YEAR);
        System.out.println("quarter  = " + quarter);

        // Using DateTimeFormatter Q / q, set the Locale to get value
        // in local format
        String quarter1 = LocalDate.of(2023, 8, 17)
                .format(DateTimeFormatter.ofPattern("q", Locale.US));
        String quarter2 = LocalDate.of(2023, 8, 17)
                .format(DateTimeFormatter.ofPattern("qq", Locale.US));
        String quarter3 = LocalDate.of(2023, 8, 17)
                .format(DateTimeFormatter.ofPattern("qqq", Locale.US));
        String quarter4 = LocalDate.of(2023, 8, 17)
                .format(DateTimeFormatter.ofPattern("qqqq", Locale.US));
        System.out.println("quarter1 = " + quarter1);
        System.out.println("quarter2 = " + quarter2);
        System.out.println("quarter3 = " + quarter3);
        System.out.println("quarter4 = " + quarter4);

        // Using older version of Java
        Date today = new Date();
        quarter = (today.getMonth() / 3) + 1;
        System.out.println("quarter = " + quarter);

        // Using java.util.Calendar object. For certain date
        // we can set the calendar date using setTime() method.
        Calendar calendar = Calendar.getInstance();
        quarter = (calendar.get(Calendar.MONTH) / 3) + 1;
        System.out.println("quarter = " + quarter);

        // Custom the quarter as text
        String[] quarters = new String[]{"Q1", "Q2", "Q3", "Q4"};
        String quarterString = quarters[quarter - 1];
        System.out.println("quarterString = " + quarterString);

And here are the result of the code snippet above:

quarter  = 1
quarter1 = 3
quarter2 = 03
quarter3 = Q3
quarter4 = 3rd quarter
quarter = 1
quarter = 1
quarterString = Q1

How do I export MySQL database schema into markdown format?

The following code example demonstrate how to export MySQL database schema into markdown table format. We get the table structure information by executing MySQL’s DESCRIBE statement.

The steps we do in the code snippet below:

  • Connect to the database.
  • We obtain the list of table name from the database / schema.
  • Executes DESCRIBE statement for each table name.
  • Read table structure information such as field, type, null, key, default and extra.
  • Write the information into markdown table format and save it into

And here are the complete code snippet.

package org.kodejava.jdbc;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;

public class DescribeMySQLToMarkDown {
    private static final String URL = "jdbc:mysql://localhost/kodejava";
    private static final String USERNAME = "root";
    private static final String PASSWORD = "";

    public static void main(String[] args) {
        String tableQuery = """
                select table_name
                from information_schema.tables
                where table_schema = 'kodejava'
                  and table_type = 'BASE TABLE'
                order by table_name;

        try (Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD)) {
            Statement stmt = connection.createStatement();
            ResultSet resultSet = stmt.executeQuery(tableQuery);
            List<String> tables = new ArrayList<>();
            while ( {

            System.out.println(tables.size() + " tables found.");

            try (BufferedWriter writer = new BufferedWriter(new FileWriter(""))) {
                for (String table : tables) {
                    System.out.println("Processing table: " + table);
                    Statement statement = connection.createStatement();
                    ResultSet descResult = statement.executeQuery("DESCRIBE " + table);

                    writer.write(String.format("Table Name: **%s**%n%n", table));
                    writer.write("| Field Name | Data Type | Null | Key | Default | Extra |\n");
                    while ( {
                        String field = descResult.getString("field");
                        String type = descResult.getString("type");
                        String nullInfo = descResult.getString("null");
                        String key = descResult.getString("key");
                        String defaultInfo = descResult.getString("default");
                        String extra = descResult.getString("extra");
                        String line = String.format("| %s | %s | %s | %s | %s | %s |%n",
                                field, type, nullInfo, key, defaultInfo, extra);
            } catch (Exception e) {
        } catch (SQLException e) {

This code snippet will produce something like below. I have tidy up the markdown for a better presentation.

Table Name: **books**

| Field Name | Data Type       | Null | Key | Default | Extra          |
| id         | bigint unsigned | NO   | PRI | null    | auto_increment |
| isbn       | varchar(30)     | NO   |     | null    |                |


Maven dependencies


Maven Central

Frameworks in Java

Do you know some frameworks of Java? Have you ever thought about the frameworks available in the Java programming language? Let’s experience & know briefly about the frameworks of Java.

But before we start discussing the types of frameworks in Java & what is frameworks for Java, let us come to know what is a framework called in normal life.

The framework is a type of template by which we can reduce our work. This means the frame of the previous work is ready. You just need to modernize it. Then you can prepare a new thing.

Finding it is quite difficult to understand. Let us take one example to clear the idea.

Suppose, yesterday you prepared a panner dish for your parents. But after taking the dinner, you find out that there is a large amount of gravy left in the pot. But there is not any panner left in the pot. The dish was so well-prepared.

So what will you do in such cases? Do you throw the remaining gravy off the dish?

No! you have decided to preserve the gravy. And the next morning, you modernize the gravy & prepared a new dish having chicken from that gravy.

This is the proper example of a framework. The gravy of the panner dish was your framework. You just modernize it, added chicken to the dish & prepared a new dish. This same thing happens in frameworks for Java.

What Is Frameworks

The framework is the predefined snippet of the code. It is very difficult to complete an application program by any developer. That is why in the framework a series of classes & functions are developed according to the necessity of the developers. Developers just need to put their written codes there. The remaining things will be completed by the framework. There are different frameworks are present for different programming languages.

Like frameworks of Java, there are JavaScript frameworks also. JavaScript framework performs the same operation. It is like the gravy of the dish which we have stated above. Just we need to add codes in the frameworks. As we have added chicken to the gravy in the above example.

Frameworks Of Java

We used to write our codes in the Java programming language by simple Java programs. But those simple Java programs will not be needed in the companies. The companies will not pay for developing a calculator in Java programming language. There we need to develop a large size of code. Developing such codes is very difficult. For that purpose, there are frameworks of Java.

These frameworks work as the model. We need to design the model on our own. We have to complete the model structure in such a way that it will fulfill the necessity of the company. Frameworks of Java are like the structure of a building. We need to build the walls; we need to decorate to live in them. If you want to get homework help Java then you can contact and pay for coding homework help.

Types Of Frameworks In Java

There are many types of frameworks in Java. According to the need of the developer, they can choose the desired framework. As per the necessity of the developer, they can choose the proper framework. Choosing an improper framework creates problems while developing the application. Here, we are going to make a list of the frameworks which play an important role in every life of Java developers.

1. Spring Frameworks Of Java

The Spring framework of Java is essential. Any Java application can develop with the help of Spring. Sometimes there may be a problem related to coupling. Due to tight coupling, there may be some issues in different classes in Java. Spring helps to create loose coupling. This change in one class, will not affect the other class.

2. Hibernate Frameworks Of Java

Sometimes there may be a problem related to the database usage by Java. The JDBC application sometimes creates difficulties while developing a table at the object level of the database. These developers need to use Hibernate. The query language used by Hibernate is known as the Hibernate Query Language (HQL). The object-level relationship can be easily made up by the Hibernate.

3. Struts Frameworks Of Java

Struts is completely an open-source platform. Anybody can download & use it for free. It helps to develop a convenient application. It helps to view the model through the easy process & user interaction. There is an XML file that helps to generate & gather the result of the analysis in a better way.

4. Dropwizard Frameworks Of Java

Dropwizard is another type of framework in Java. It is a wizard. It helps to complete the application by configuring it. It helps to complete the application by logging, configuring & changing the metrics of the application. It takes libraries to form the Java ecosystem & provides a single framework interface.

5. Grail Frameworks Of Java

It is the most important type of framework in Java. It is appropriate for beginners. Beginners who want to learn the frameworks of Java, first need to know the Grail. But it is not able to run with Java programming language. It runs with the Groovy language. Groovy language is similar to the Java programming language. But it has more features than Java. Also, it is very easy. That is why it is advisable to start the journey of the Frameworks of Java with Grail.


As we saw the frameworks of Java are very important. It is advisable to clear the basic concept of Java programming language in a good manner. It is a very important first step.

Frameworks for Java are the building boxes for developing applications related to the Java programming language.

EduBirdie Code Writing Services for Students – Review

We can all agree that computer programming significantly influenced the way our lives look today. There are so many things we use and rely on that would not exist without code writing. The whole online realm would still be an advanced idea. The term source code stands for the layers of knowledge, creativity, and constant effort to make products better in every sense of the word. Most of us, consumers, can’t even conceptualize this building process. We use it without knowing how to make a program or what it takes to reach the final product. For that reason, the slight mystic aura around people who mastered code making is more than well deserved.

Code writing as a profession

To reach a high level of professionalism students who choose this career have to put a lot of work and time into it. This is where EduBirdie and other services can make a huge difference by providing experienced insight. Programming is the set of many tech-related activities that surpasses the simple term “writing code”. In the beginning, the learning curve might go down due to the number of programming languages with Java, C++, PHP, and Python being the most popular ones. There are numerous functions, procedures, concepts, and variables to adopt and apply.

Photo by Christina Morillo

According to programmers, learning how to write code is not the most difficult ever. Once the first phase passes and the logic behind programming have been fully comprehended things will get much easier. In their opinion, the two most important factors are finding the right sources to learn from and a good mentor. A college degree is equally important as practical knowledge, experience, and a smartly built portfolio.

Learning computer programming with EduBirdie

With code writing college assignments even the most confident students can get stuck with the problem that they just can’t find the solution for. Online is the first place new generations are going, to find reliable professional help. Unfortunately, not every online service is trustworthy and responsible. Same as for any other business, the smart thing would be to check edubirdie reviews, users’ ratings, and other useful sources to learn about the level of service quality and customer satisfaction. EduBirdie exists since 2015 so there is plenty of positive feedback that positions them as experts in providing this type of service. For any student that seeks assistance with code writing assignments maintaining communication with customer service and code writer in person are among the most praised qualities. In terms of educational values, EduBirdie can provide reliable sources of knowledge and experience. Simultaneously, its code writers play the mentoring role by offering examples and possible solutions to the assignment issues.

Review of EduBirdie code writing service

Let’s start with the ratings on the review websites. The scores always maintain between 4.6 and 5 stars and place it among the three most popular services. The rating is based on several thousand users’ reviews.

Probably the most painful fact, EduBirdie is not the cheapest option on the market. Also, unlike most writing services it has a bidding pricing system that can be confusing, especially for first-time users. However, this also means that this service is capable of hiring experts and high-profile professional code writers.

EduBirdie claims that all the work is unique and original, and offers revision as an option. Furthermore, a student can pick the same code writer for different assignments and extend the learning journey under the same guidance. Another positive thing is the opportunity for students to release their deposit once the quality of the work meets the requirements.

While browsing through the reviews we couldn’t find any complaint about confidentiality or delivery schedule. The only objection that was repeated in the older reviews is the lack of discounts. Judging by the latest first order promotional code, EduBirdie reacted to these comments and is actively changing the discount policy.

A significant number of positive reviews are addressed to customer service. It seems that EduBirdie is seriously determined to be online available 24/7, highly responsive to calls, and supportive in resolving potential issues.


The number of customers seeking assistance speaks loud enough about their legitimacy and professionalism. Since the quality of the work depends on the skills of the particular code writer, the system might resemble a lottery. Due to only a few negative reviews, it’s safe to assume that EduBirdie chooses its code writers with great care.