Android Open Source - o365api-android-get-events-app Local Date Time Converter






From Project

Back to project page o365api-android-get-events-app.

License

The source code is released under:

MIT License

If you think the Android project o365api-android-get-events-app listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.mattleib.myinboxapplication;
// w w w.  j a v  a 2  s.c o  m
import android.text.format.Time;

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

/**
 * Created by matthias on 2/1/2015.
 */
public class LocalDateTimeConverter {

    private Time mLocalTime;

    public LocalDateTimeConverter(String utcDateRFC3339) {
        //RFC3339
        //"Start": "2015-01-23T20:00:00Z",
        //"End": "2015-01-23T21:00:00Z",
        Time localTime = new Time();
        localTime.parse3339(utcDateRFC3339);
        int utcOffset = TimeZone.getDefault().getOffset(localTime.toMillis(false));
        localTime.set(localTime.toMillis(false) + utcOffset);
        this.mLocalTime = localTime;
    }

    public String getLocalDayString() {
        String s = mLocalTime.format("%m/%d/%Y");
        return s;
    }
    public String getLocalTimeString() {
        //String s = mLocalTime.format("%H:%M:%S");
        String s = mLocalTime.format("%H:%M");
        return s;
    }

    public String getLocalDayTimeString() {
        String s = mLocalTime.format("%m/%d/%Y %H:%M:%S");
        return s;
    }

    public boolean IsAm() {
        String s = mLocalTime.format("%p");
        boolean am = s.toLowerCase().equals("am");
        return am;
    }

    public String getLocalDayOfWeekString() {
        SimpleDateFormat sdf = new SimpleDateFormat("EEEE");
        Date d = new Date();
        d.setTime(mLocalTime.toMillis(false));
        // String dayOfTheWeek = android.text.format.DateFormat.format("EEEE", d);
        String dayOfTheWeek = sdf.format(d);
        return dayOfTheWeek;
    }

}




Java Source Code List

com.example.mattleib.myinboxapplication.AppConfig.java
com.example.mattleib.myinboxapplication.AppHelper.java
com.example.mattleib.myinboxapplication.ApplicationTest.java
com.example.mattleib.myinboxapplication.Constants.java
com.example.mattleib.myinboxapplication.DataTypes.java
com.example.mattleib.myinboxapplication.EmailAddress.java
com.example.mattleib.myinboxapplication.EmptyItem.java
com.example.mattleib.myinboxapplication.EventItem.java
com.example.mattleib.myinboxapplication.EventItemsFragment.java
com.example.mattleib.myinboxapplication.Helpers.java
com.example.mattleib.myinboxapplication.InMemoryCacheStore.java
com.example.mattleib.myinboxapplication.Item.java
com.example.mattleib.myinboxapplication.LocalDateTimeConverter.java
com.example.mattleib.myinboxapplication.Location.java
com.example.mattleib.myinboxapplication.MainActivity.java
com.example.mattleib.myinboxapplication.Organizer.java
com.example.mattleib.myinboxapplication.PreferenceSetting.java
com.example.mattleib.myinboxapplication.PreferenceSettings.java
com.example.mattleib.myinboxapplication.SectionItem.java
com.example.mattleib.myinboxapplication.SettingsActivity.java
com.example.mattleib.myinboxapplication.SettingsFragment.java
com.example.mattleib.myinboxapplication.SimpleAlertDialog.java