Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Main {

    public static void main(String[] args) {

    }

    public static LocalDateTime getLocalDateTimeFromDB(ResultSet rs, String column) throws SQLException {
        String date = rs.getString(column);
        if (date != null) {
            return LocalDateTime.parse(date, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
        } else {
            return null;
        }
    }

    public static String getDBValueFromLocalDateTime(LocalDateTime start) {
        if (start != null) {
            return start.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
        } else {
            return null;
        }
    }
}