Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.util.Log;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import java.util.TimeZone;

public class Main {
    private static String TAG = "SunriseUtil";

    public static String getHours(String dateString) {

        SimpleDateFormat parserSDF = new SimpleDateFormat("HH:mm:ss");
        SimpleDateFormat formater = new SimpleDateFormat("HH:mm");

        parserSDF.setTimeZone(TimeZone.getTimeZone("UTC"));
        formater.setTimeZone(TimeZone.getTimeZone("UTC"));
        Date date = null;
        try {
            parserSDF.setTimeZone(TimeZone.getTimeZone("UTC"));
            date = parserSDF.parse(dateString);
        } catch (ParseException e) {
            Log.d(TAG, e.getMessage());
        }

        return formater.format(date);
    }
}