List of usage examples for java.util Date getTime
public long getTime()
From source file:com.threepillar.labs.meeting.Main.java
public static void googleCalendarInvite() throws Exception { // set the client/secret and OAUTH2 AccessToken, RefreshToken and // ExpiryTime Properties props = new Properties(); props.setProperty(GoogleInviteImpl.CLIENT_ID, "XXXXXXX"); props.setProperty(GoogleInviteImpl.CLIENT_SECRET, "XXXXXXX"); props.setProperty(GoogleInviteImpl.ACCESS_TOKEN, "XXXXXXX"); props.setProperty(GoogleInviteImpl.REFRESH_TOKEN, "XXXXXXX"); props.setProperty(GoogleInviteImpl.EXPIRY_TIME_IN_MILLIS, "XXXXXXX"); // set the organizer of the event. Participant from = new Participant("From", "From@gmail.com", ParticipantType.REQUIRED); // set the attendee of the event. Participant attendee1 = new Participant("Attendee", "attendee@gmail.com", ParticipantType.REQUIRED); List<Participant> list = new ArrayList<Participant>(); list.add(attendee1);//from ww w .j a v a 2 s. co m Date startDate = new Date(System.currentTimeMillis() + 30000); Date endDate = new Date(startDate.getTime() + 1800000); Invite invite = new GoogleInviteImpl(props); invite.sendInvite("Testing Event", "Testing dummy event", from, list, startDate, endDate, "Delhi"); }
From source file:Main.java
public static String changeStringToDate2(String str) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); java.util.Date date6 = null; try {//from ww w . j a va 2s . c om date6 = sdf.parse(str); java.sql.Date date7 = new java.sql.Date(date6.getTime()); return date7.toString(); } catch (ParseException e) { e.printStackTrace(); return ""; } }
From source file:Main.java
public static boolean isPastWeek(Date date) { Date currentDate = new Date(); Date firstTimeOfWeek = firstTimeOfWeek(currentDate); float currentSecond = secondFromMilisecond(firstTimeOfWeek.getTime()); float actuallySecond = secondFromMilisecond(date.getTime()); float delta = actuallySecond - currentSecond; Log.v("Time currentDate", "" + currentDate); Log.v("Time currentSecond", "" + firstTimeOfWeek); Log.v("Time actuallySecond", "" + date); Log.v("Time delta", "" + delta); if (delta >= 0 && delta < 60 * 60 * 24 * 7) { return true; }/*from w w w. ja v a2 s . c o m*/ return false; }
From source file:DateUtils.java
/** * Converts a given time as an instance of {@link java.util.Date} into a {@link XMLGregorianCalendar} object. * * @param date/*from ww w . ja v a 2 s . c o m*/ * A given time as an instance of <code>java.util.Date</code> * @return A new instance of <code>XMLGregorianCalendar</code> representing the input time */ public static XMLGregorianCalendar toXmlGregorianCalendar(final Date date) { return toXmlGregorianCalendar(date.getTime()); }
From source file:Main.java
public static void smoothToTransparentFromColor(final View view, final int color) { Date firstDate = new Date(); final long firstTime = firstDate.getTime(); executeAsyncTask(new AsyncTask<Void, Integer, Void>() { int n = 1, t = 4000; boolean increaseN; @Override//from w w w. ja v a 2 s . c o m protected Void doInBackground(Void... params) { while (!isCancelled()) { Date currentDate = new Date(); long diffTime = currentDate.getTime() - firstTime; double y = getCosY(diffTime); int alpha = (int) (y * Color.alpha(color)); int resultColor = setAlphaComponent(color, alpha); if (alpha < 0.038 * 255) { publishProgress(0); this.cancel(true); return null; } publishProgress(resultColor, alpha); try { Thread.sleep(38); } catch (InterruptedException e) { e.printStackTrace(); } } return null; } @Override protected void onProgressUpdate(Integer... values) { super.onProgressUpdate(values); view.setBackgroundColor(values[0]); } }); }
From source file:com.threepillar.labs.meeting.Main.java
public static void sendEmailInvite() throws Exception { // set the properties to send email Properties props = new Properties(); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.socketFactory.port", "465"); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.port", "465"); props.put("username", ""); props.put("password", ""); // set the organizer of the event Participant from = new Participant("From", "from@from.com", ParticipantType.REQUIRED); // set the attendees of the event Participant attendee1 = new Participant("Attendee1", "attendee1@attendee.com", ParticipantType.REQUIRED); List<Participant> list = new ArrayList<Participant>(); list.add(attendee1);/*from w w w . j av a 2 s. com*/ Invite invite = new EmailInviteImpl(props); Date startDate = new Date(System.currentTimeMillis() + 600000); Date endDate = new Date(startDate.getTime() + 1800000); invite.sendInvite("Testing Event", "Testing dummy event", from, list, startDate, endDate, "Delhi"); }
From source file:Main.java
public static String getTimeString(Date fromdate) { long then;// w w w .jav a 2 s. com then = fromdate.getTime(); Date date = new Date(then); StringBuffer dateStr = new StringBuffer(); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); Calendar now = Calendar.getInstance(); int days = daysBetween(calendar.getTime(), now.getTime()); int minutes = hoursBetween(calendar.getTime(), now.getTime()); int hours = minutes / 60; if (days == 0) { int second = minuteBetween(calendar.getTime(), now.getTime()); if (minutes > 60) { if (hours >= 1 && hours <= 24) { dateStr.append(hours).append("h"); } } else { if (second <= 10) { dateStr.append("Now"); } else if (second > 10 && second <= 30) { dateStr.append("few seconds ago"); } else if (second > 30 && second <= 60) { dateStr.append(second).append("s"); } else if (second >= 60 && minutes <= 60) { dateStr.append(minutes).append("m"); } } } else if (hours > 24 && days <= 7) { dateStr.append(days).append("d"); } else { dateStr.append(DateUtils.getRelativeTimeSpanString(date.getTime(), System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS)); } return dateStr.toString(); }
From source file:Main.java
public static boolean isPastMonth(Date date) { Date currentDate = new Date(); Date firstTimeOfMonth = firstTimeOfMonth(currentDate); float currentSecond = secondFromMilisecond(firstTimeOfMonth.getTime()); float actuallySecond = secondFromMilisecond(date.getTime()); float delta = actuallySecond - currentSecond; Log.v("Time currentDate", "" + currentDate); Log.v("Time currentSecond", "" + firstTimeOfMonth); Log.v("Time actuallySecond", "" + date); Log.v("Time delta", "" + delta); if (delta > 0 && delta <= 60 * 60 * 24 * 30) { return true; }/*from w ww . ja va 2 s .co m*/ return false; }
From source file:Main.java
public static long getTimeOfDate(String dateTime) { try {// w w w . j a va 2 s . c om Date parse = dateFormat.parse(dateTime); long time = parse.getTime(); return time; } catch (ParseException e) { e.printStackTrace(); } return 0; }
From source file:ch.admin.suis.msghandler.util.ISO8601Utils.java
/** * Formats the given date in the ISO-8601 format (yyyy-MM-ddTHH:mm:ss.SSS+HH:mm). * * @param date the date; if it is <code>null</code>, then this method returns <code>null</code> * @return the formatted date or <code>null</code> *///w ww . j a va 2 s . c o m public static String format(Date date) { return null == date ? null : DATE_TIME_WITH_MS.print(date.getTime()); }