Get GMT String as EEEE MMM dd HH:mm:ss Z yyyy format - Android java.util

Android examples for java.util:Year

Description

Get GMT String as EEEE MMM dd HH:mm:ss Z yyyy format

Demo Code


//package com.java2s;
import android.util.Log;

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

public class Main {
    static String TAG = "CalendarHandler";

    public static String GMT2String(String datetime) {
        String res = "DATE ";
        Calendar calendar = Calendar.getInstance();
        try {/* w w w.  j  ava  2  s .  c o  m*/
            SimpleDateFormat format = new SimpleDateFormat(
                    "EEEE MMM dd HH:mm:ss Z yyyy");
            Date date = format.parse(datetime);
            calendar.setTime(date);

        } catch (ParseException e) {
            Log.e(TAG, res);
        }
        return calendar.get(Calendar.HOUR_OF_DAY) + ":"
                + calendar.get(Calendar.MINUTE);
    }
}

Related Tutorials