Android Open Source - Alkomer Data Time






From Project

Back to project page Alkomer.

License

The source code is released under:

MIT License

If you think the Android project Alkomer 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 cz.jmx.tomik.alkomer.android.tools;
//  w w  w. j a va  2 s.c om
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import android.content.Context;
import android.util.Log;

public class DataTime {
  
  static public int getDateHour(Date d) {
      Calendar calendar = GregorianCalendar.getInstance();
      calendar.setTime(d);
      return calendar.get(Calendar.HOUR_OF_DAY);
    }        
    
  static public Date getNextHour(Date d, int hours) {
      Calendar calendar = GregorianCalendar.getInstance();
      calendar.setTime(d); 
      calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY)+hours);
      calendar.set(Calendar.MINUTE, 0);
      calendar.set(Calendar.SECOND, 0);
      return calendar.getTime();
    }    
    
  static public String getWeekDay(Date d) {
      final String[] weekDays = {"??", "NE", "PO", "?T", "ST", "?T", "P?", "SO"};
      
      Calendar calendar = GregorianCalendar.getInstance();
      calendar.setTime(d);     
      return weekDays[calendar.get(Calendar.DAY_OF_WEEK)];
    }
    
  static public String getFormalDate(Date d) {
      Calendar calendar = GregorianCalendar.getInstance();
      calendar.setTime(d);     
      return calendar.get(Calendar.DAY_OF_MONTH)+"."+(calendar.get(Calendar.MONTH)+1)+".";
    }    
    
  static public Date getNextDay(Date d, int days) {
      Calendar calendar = GregorianCalendar.getInstance();
      calendar.setTime(d); 
      calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH)+days);
      calendar.set(Calendar.HOUR_OF_DAY, 12);
      calendar.set(Calendar.MINUTE, 12);
      calendar.set(Calendar.SECOND, 12);
      calendar.set(Calendar.MILLISECOND, 12);
      return calendar.getTime();
    }   
  
  static public Date convertFromStringToDate(String dateTime, Context context) {
    SimpleDateFormat iso8601Format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date date = null;
    try {
      date = iso8601Format.parse(dateTime);
    } catch (ParseException e) {
      Log.e("Parsing date", e.getMessage());
    }

    return date;
    }
  
  static public String convertFromDateToString(Date date) {
    SimpleDateFormat iso8601Format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    return iso8601Format.format(date);
    }  

}




Java Source Code List

cz.jmx.tomik.alkomer.android.BaseActivity.java
cz.jmx.tomik.alkomer.android.DashboardActivity.java
cz.jmx.tomik.alkomer.android.DrinkListActivity.java
cz.jmx.tomik.alkomer.android.ForgottenPasswordActivity.java
cz.jmx.tomik.alkomer.android.GlassListActivity.java
cz.jmx.tomik.alkomer.android.LoginActivity.java
cz.jmx.tomik.alkomer.android.Main.java
cz.jmx.tomik.alkomer.android.RegistrationActivity.java
cz.jmx.tomik.alkomer.android.SettingsActivity.java
cz.jmx.tomik.alkomer.android.StatisticsActivity.java
cz.jmx.tomik.alkomer.android.StatisticsFlowAdapter.java
cz.jmx.tomik.alkomer.android.database.DataHelper.java
cz.jmx.tomik.alkomer.android.drinks.DrinkAdapter.java
cz.jmx.tomik.alkomer.android.drinks.Drink.java
cz.jmx.tomik.alkomer.android.drinks.Drinks.java
cz.jmx.tomik.alkomer.android.drinks.GlassAdapter.java
cz.jmx.tomik.alkomer.android.drinks.Glass.java
cz.jmx.tomik.alkomer.android.models.Gender.java
cz.jmx.tomik.alkomer.android.models.User.java
cz.jmx.tomik.alkomer.android.threads.DeleteDrinkThread.java
cz.jmx.tomik.alkomer.android.threads.DeleteDrinksThread.java
cz.jmx.tomik.alkomer.android.threads.DrinkThread.java
cz.jmx.tomik.alkomer.android.threads.ForgottenPasswordAsyncTask.java
cz.jmx.tomik.alkomer.android.threads.ImageDownloadAsyncTask.java
cz.jmx.tomik.alkomer.android.threads.LoginAsyncTask.java
cz.jmx.tomik.alkomer.android.threads.RegistrationAsyncTask.java
cz.jmx.tomik.alkomer.android.threads.UpdateSettingsThread.java
cz.jmx.tomik.alkomer.android.tools.Calculator.java
cz.jmx.tomik.alkomer.android.tools.DataTime.java
cz.jmx.tomik.alkomer.android.tools.EmailValidator.java
cz.jmx.tomik.alkomer.android.tools.IntEditTextPreference.java