Android Open Source - UniApp Util






From Project

Back to project page UniApp.

License

The source code is released under:

MIT License

If you think the Android project UniApp 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 it.nic.uniapp.util;
//from   ww w. ja v  a2 s.c o m

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;


import android.content.Context;
import android.widget.DatePicker;
import android.widget.Toast;

public class Util {

  public static boolean isNullOrEmpty(String s) {
    return s == null || s.trim().length() == 0;
  }

  public static void showToast(Context context, String message) {
    int duration = Toast.LENGTH_LONG;
    Toast toast = Toast.makeText(context, message, duration);
    toast.show();
  }
  
  public static String getDateFromDatePicker(DatePicker datePicker){
      int day = datePicker.getDayOfMonth();
      int month = datePicker.getMonth();
      int year =  datePicker.getYear();
      
      Calendar cal = Calendar.getInstance();
      cal.set(year, month, day);
      SimpleDateFormat format1 = new SimpleDateFormat("dd/MM/yy");
      System.out.println(cal.getTime());
    

      String formatted = format1.format(cal.getTime());
      System.out.println(formatted);

      

      return formatted;
  }
  
  public static Calendar getCalendarFromString(String date){
    
    String[] dateParts = date.split("/");
    int year = Integer.parseInt("20"+dateParts[2]);
    int month = Integer.parseInt(dateParts[1])-1;
    int day = Integer.parseInt(dateParts[0]);

    Calendar calendar = Calendar.getInstance();
    calendar.set(year, month, day);
    
    return calendar;
   
  }
  
  public static String getDateFormattedFromString(String m){
    
      DateTimeFormatter format = DateTimeFormat.forPattern("dd/MMMM/yyyy").withLocale(Locale.ITALY);
      DateTime instance        = format.parseDateTime(m.toLowerCase());
      int month = instance.getMonthOfYear()-1;
      int day = instance.getDayOfMonth();
      int year = instance.getYear();
      Calendar c = Calendar.getInstance();
      c.set(year, month, day);
      SimpleDateFormat f = new SimpleDateFormat("dd/MM/yy");
      String data = f.format(c.getTime());
      
     
      return data;  
    
  }
  

}




Java Source Code List

it.nic.uniapp.AddEsame.java
it.nic.uniapp.CalendarioEsami.java
it.nic.uniapp.FunzioniEsami.java
it.nic.uniapp.ListaEsami.java
it.nic.uniapp.MainActivity.java
it.nic.uniapp.PopUpWindow.java
it.nic.uniapp.UpdateEsame.java
it.nic.uniapp.adapters.EsameAdapter.java
it.nic.uniapp.adapters.GridCellAdapter.java
it.nic.uniapp.cmp.EsameRowControl.java
it.nic.uniapp.core.Constants.java
it.nic.uniapp.core.PageLoader.java
it.nic.uniapp.db.DBHandler.java
it.nic.uniapp.db.DatabaseConfigUtil.java
it.nic.uniapp.db.DatabaseHelper.java
it.nic.uniapp.db.EsameEntity.java
it.nic.uniapp.db.IDBHandler.java
it.nic.uniapp.util.Util.java