Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: BEER-WARE LICENSE 

import java.util.HashMap;

public class Main {
    public static final String YEAR = "year";
    public static final String MONTH = "mon";
    public static final String DAY = "day";
    public static final String HOUR = "hour";
    public static final String MIN = "min";

    public static HashMap<String, Object> getDateFromLJString(String dateString) {
        final HashMap<String, Object> result = new HashMap<String, Object>();

        if (dateString == null || dateString.length() == 0) {
            return result;
        }

        final String[] dateTime = dateString.split(" ");
        final String[] dateItems = dateTime[0].split("-");
        result.put(YEAR, dateItems[0]);
        result.put(MONTH, dateItems[1]);
        result.put(DAY, dateItems[2]);

        final String[] timeItems = dateTime[1].split(":");
        result.put(HOUR, timeItems[0]);
        result.put(MIN, timeItems[1]);

        return result;
    }
}