Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.util.Date;

import java.util.Locale;

import java.util.TimeZone;

import android.util.Log;

public class Main {
    public static Date ConvertFromWebService(final String strDate) {

        final String[] formats = new String[] { "yyyy-MM-dd'T'HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss.SSSXXX",
                "yyyy-MM-dd'T'HH:mm:ss", "yyyy-MM-dd'T'HH:mm", "yyyy-MM-dd" };

        for (final String frm : formats) {
            try {
                final SimpleDateFormat format = new SimpleDateFormat(frm, Locale.US);
                format.setTimeZone(TimeZone.getTimeZone("UTC"));
                return format.parse(strDate);
            } catch (final Exception ex) {
                Log.e("IGWHelper", "Failed to convert Web Service Date.", ex);
            }
        }
        return null;
    }
}