Time setToNow - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Time setToNow method.

This code example shows how to use the following methods:setToNow, toMillis
 
@RunWith(TestRunners.WithDefaults.class) 
public class TimeTest { 
    @Test 
    public void shouldSetToNow() throws Exception { 
        Time t = new Time();
        t.setToNow();
        assertThat(t.toMillis(false)).isNotEqualTo(0l);
    } 
 
    @Test 
    public void shouldHaveNoArgsConstructor() throws Exception { 
        Time t = new Time();
        assertNotNull(t.timezone);
    } 
 
    @Test 
    public void shouldHaveCopyConstructor() throws Exception { 
        Time t = new Time();
        t.setToNow();
8
CodeRank
This code example shows how to use the following methods:setToNow, toMillis
    } 
     
    /********** Time **********/ 
     
    public static long currentTimeInMillis() { 
        Time time = new Time();
        time.setToNow();
        return time.toMillis(false);
    } 
} 
7
CodeRank
This code example shows how to use the following methods:format, setToNow
			} 
		}; 
	}; 
	public static String now()
	  { 
	    Time localTime = new Time("Asia/Beijing");
	    localTime.setToNow();
	    return localTime.format("%Y-%m-%d");
	  } 
	public static String nametimeString= now();
       
	public UpdateManager(Context context, String version,String force,String apkurl,String description) {
		appkey = CommonUtil.getAppKey(context);
		this.newVersion = version;
		this.force=force;
		this.apkUrl=apkurl;
		this.mContext = context;
		this.updateMsg= this.Msg+"\n"+version+":"+description;
		this.saveFile=savePath+nametimeString;
	} 
7
CodeRank
This code example shows how to use the following methods:setToNow, switchTimezone
      hand.draw(canvas);
      canvas.restore();
    } 
 
    private void onTimeChanged() { 
        mCalendar.setToNow();
 
        if (mTimeZoneId != null) {
            mCalendar.switchTimezone(mTimeZoneId);
        } 
 
        int hour = mCalendar.hour;
        int minute = mCalendar.minute;
        int second = mCalendar.second;
  //      long millis = System.currentTimeMillis() % 1000; 
 
        mSeconds = second;//(float) ((second * 1000 + millis) / 166.666);
        mMinutes = minute + second / 60.0f;
        mHour = hour + mMinutes / 60.0f;
        mChanged = true;

7
CodeRank
This code example shows how to use the following methods:setToNow, toMillis
        assertEquals("Daily recurring event should have been deleted.", 
                     countBeforeNewEvent, getEventsCount());
    } 
 
    public void testCreateAllDayEvent() throws Exception { 
        Time time = new Time();
        time.setToNow();
        long dtStart = time.toMillis(false);
        long dtEnd = time.toMillis(false) + ONE_HOUR_IN_MILLIS;
        EventInfo allDayEvent = new EventInfo("allday0", dtStart, dtEnd, true);
 
        int countBeforeNewEvent = getEventsCount();
        insertEvent(allDayEvent);
 
        assertTrue("An all-day event should have been created.", 
                   getEventsCount() > countBeforeNewEvent);
    } 
 
    public void testEditEventTitle() throws Exception { 
        Cursor cursor;
6
CodeRank
This code example shows how to use the following methods:setToNow, switchTimezone, toMillis
 
        // NOTE: It's safe to do these after registering the receiver since the receiver always runs 
        // in the main thread, therefore the receiver can't run before this method returns. 
 
        // The time zone may have changed while the receiver wasn't registered, so update the Time 
        mCalendar = new Time();
 
        // Make sure we update to the current time 
        onTimeChanged(); 
 
        // tick the seconds 
        post(mClockTick);
 
    } 
 
    @Override 
    protected void onDetachedFromWindow() { 
        super.onDetachedFromWindow(); 
        if (mAttached) {
            getContext().unregisterReceiver(mIntentReceiver);

6
CodeRank
This code example shows how to use the following methods:getActualMaximum, normalize, set, setToNow
            if (visible) {
                if (!mWatcherRegistered) {
                    mWatcherRegistered = true;
                    registerReceiver(mWatcher, mFilter, null, mHandler);
                } 
                mCalendar = new Time();
                mCalendar.setToNow();
            } else { 
                if (mWatcherRegistered) {
                    mWatcherRegistered = false;
                    unregisterReceiver(mWatcher);
                } 
                mHandler.removeCallbacks(mDrawClock);
            } 
            drawFrame(); 
        } 
 
        @Override 
        public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
            super.onSurfaceChanged(holder, format, width, height);

6
CodeRank
This code example shows how to use the following methods:set, setToNow, toMillis
     
    private void processTodaysMiqaat() { 
    	String notificationTitle = "";
    	String notificationText = "";
    	 
    	Time time = new Time();
    	time.setToNow(); 
    	time.set(time.toMillis(false)+86400000L); // add 24 hours to make it tomorrow
    	 
    	int[] date = UtilCalendar.getMisriDate(time);
    	String miqaat = UtilCalendar.getMiqaat(date);
    	 
    	if (nextNamaaz[0] == 6 && nextNamaaz[1] < 0.0028 && miqaat != "") {
    		notificationTitle = "Miqaats for " + Integer.toString(date[0]) + " " + UtilCalendar.getMisriMonth(date[1]) + " " + Integer.toString(date[2]) + "H" ;
			notificationText = miqaat;
    		showMiqaatNotification(mNM, context, notificationText, notificationTitle);
    	} 
    } 
     
    static public void showMiqaatNotification(NotificationManager mNM, Context context, String notificationText, String notificationTitle) {
6
CodeRank
This code example shows how to use the following methods:format, setToNow
		if (android.os.Build.VERSION.SDK_INT >= 11)
			if(v.hasVibrator()) v.vibrate(1000);
		nuanceObject.initializeSpeechKit(thisContext, errorHandler);
		//1. Run weather, mail, etc. functions and get input 
 
		Time now = new Time();
		now.setToNow();
		String day = now.format("%A %B %d");
		int hour = Integer.parseInt(now.format("%I"));
		String meridien = now.format("%p");
		int minute = Integer.parseInt(now.format("%M"));
		String time = ""+hour+", "+(minute<10 ? "oh "+(minute==0? "clock":minute) : minute)+meridien;
		String greeting="";
		if(meridien.equals("am")){
			if(hour<6)
				greeting="Why are you up? Go to sleep. It's ";
			else if(hour<10)
				greeting="Good morning. It's ";
			else 
				greeting="Good morning, lazy. It's ";
6
CodeRank
This code example shows how to use the following methods:setToNow, toMillis
	 * @param prefix the prefix to be used for this temp file. 
	 * @param suffix the suffix to be used for this temp file. 
	 * @return the name of the temp file. 
	 */ 
	public static String getTempFile(String prefix, String suffix) {
		Time now = new Time();
		now.setToNow();
		Random rnd = new Random(now.toMillis(false));
		Long val = now.toMillis(false) + rnd.nextLong();
		String filename = Long.toHexString(val);
		filename = prefix + filename + suffix;
		return filename;
	} 
 
	/** 
	 * Get a temporary filename using Time + Random. The prefix and 
	 * suffix for this temp file will be "" and ".temp" respectively. 
	 * @return the name of the temp file. 
	 */ 
	public static String getTempFile() {
6
CodeRank

Related Time setToNow Questions & Answers:

setToNow Method Overview
Sets the time of the given Time object to the current time.
See Code Examples for other Android Time Methods: