Hi, I am Kiru 👋 an indie hacker, a problem solver and vim-lover. I build projects to make the life of others and mine easier.

This page is intended to collect all my projects and some thoughts.

Java Enum and extract in SQL

TIL 13.03.2017

Java class with enum switch statement is translated to switch statement with ordinal:

public enum  MyEnum {
    YES,
    NO;

    public static void main(String[] args) {
        MyEnum e = NO;
        switch (e) { // uses e.ordinal()
            case YES:
                System.out.println("Yes");
                break;
            case NO:
                System.out.println("No");
                break;
        }
    }
}

You can use extract() in oracle in order to get the date parts

select
    extract(year from created_timestamp),
    extract(month from created_timestamp),
    extract(day from created_timestamp)
from student;

Source: EXTRACT

Learn more: