Android Open Source - TodoList Date Utils






From Project

Back to project page TodoList.

License

The source code is released under:

Apache License

If you think the Android project TodoList 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 lyc.app;
/*from www.j  a v a 2  s .c  o m*/
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {

  private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

  private DateUtils() {

  }

  public static String format(long milliseconds) {
    return format.format(new Date(milliseconds));
  }

  public static String format(long milliseconds, String formatter) {
    return format(new Date(milliseconds), formatter);
  }

  public static String format(Date date, String formatter) {
    SimpleDateFormat newFormat = new SimpleDateFormat(formatter);
    return newFormat.format(date);
  }


  public static long parse(String dateStr) {
    if (dateStr == null) {
      throw new IllegalArgumentException();
    }
    try {
      return format.parse(dateStr).getTime();
    } catch (ParseException e) {
      e.printStackTrace();
    }
    return System.currentTimeMillis();
  }

  public static boolean afterToday(String dateStr) {
    if (dateStr == null) {
      throw new IllegalArgumentException();
    }

    try {
      return format.parse(dateStr).after(new Date());
    } catch (ParseException e) {
      e.printStackTrace();
    }
    return false;
  }
}




Java Source Code List

lyc.app.AddActivity.java
lyc.app.App.java
lyc.app.BootReceiver.java
lyc.app.DateUtils.java
lyc.app.MainActivity.java
lyc.app.TodoService.java
lyc.app.adapter.TodoCursorAdapter.java
lyc.app.fragment.FinishedTodoFragment.java
lyc.app.fragment.UnFinishedTodoFragment.java
lyc.app.provider.TodoProvider.java
lyc.simplesqlite.annotation.Column.java
lyc.simplesqlite.annotation.Table.java
lyc.simplesqlite.exception.AnnotationNotFoundException.java
lyc.simplesqlite.util.MetaData.java
lyc.simplesqlite.util.StringUtils.java