Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.Locale;

public class Main {
    /**
     * Gets the day of week out of a date.
     *
     * @param dateString represents the date.
     * @return the day of week of the date.
     */
    public static String dateToDayOfWeek(String dateString) {
        Date date = new Date();
        try {
            date = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.GERMAN).parse(dateString);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        DateFormat dtfmt = new SimpleDateFormat("EEE", Locale.ENGLISH);
        String dayOfWeek = dtfmt.format(date);
        return dayOfWeek;
    }
}