get Current Day Time - Android java.util

Android examples for java.util:Day

Description

get Current Day Time

Demo Code

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

public class Main {

  public static final SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy-MM-dd");

  public static long getCurrentDayTime() {
    Date d = new Date(System.currentTimeMillis());
    String formatDate = yearFormat.format(d);
    try {/*  w w  w .j  a v a  2s.  c o  m*/
      return (yearFormat.parse(formatDate)).getTime();
    } catch (ParseException e) {
      e.printStackTrace();
    }
    return 0;
  }

}

Related Tutorials