EzDev.org

time interview questions

Top 15 time interview questions

24341 Jobs openings for time


How to recursively find and list the latest modified files in a directory with subdirectories and times?

Operating system: Linux

Filesystem type: ext3

Preferred solution: bash (script/oneliner), ruby, python

I have several directories with several subdirectories and files in them. I need to make a list of all these directories that is constructed in a way such that every first-level directory is listed next to the date and time of the latest created/modified file within it.

To clarify, if I touch a file or modify its contents a few subdirectory levels down, that timestamp should be displayed next to the first-level directory name. Say I have a directory structured like this:

./alfa/beta/gamma/example.txt

and i modify the contents of the file 'example.txt', I need that time displayed next to the first-level directory 'alfa' in human readable form, not epoch. I've tried some things using find, xargs, sort and the likes but I can't get around the problem that the filesystem timestamp of 'alfa' doesn't change when I create/modify files a few levels down.


Source: (StackOverflow)

Getting current date and time in JavaScript

I have a script that prints the current date and time in JavaScript, but the DATEis allways wrong. Here is the code:

var currentdate = new Date();
var datetime = "Last Sync: " + currentdate.getDay() + "/"+currentdate.getMonth() 
+ "/" + currentdate.getFullYear() + " @ " 
+ currentdate.getHours() + ":" 
+ currentdate.getMinutes() + ":" + currentdate.getSeconds();

It should print 18/04/2012 15:07:33 and prints 3/3/2012 15:07:33

Any help? Thanks


Source: (StackOverflow)

Displaying the build date

I currently have an app displaying the build number in its title window. That's well and good except it means nothing to most of the users, who want to know if they have the latest build - they tend to refer to it as "last Thursday's" rather than build 1.0.8.4321.

The plan is to put the build date there instead - So "App built on 21/10/2009" for example.

I'm struggling to find a programmatic way to pull the build date out as a text string for use like this.

For the build number, I used:

Assembly.GetExecutingAssembly().GetName().Version.ToString()

after defining how those came up.

I'd like something like that for the compile date (and time, for bonus points).

Pointers here much appreciated (excuse pun if appropriate), or neater solutions...

Mark


Source: (StackOverflow)

What's the difference between DateTime and Time in Ruby?

And what factors would cause me to choose one or the other?


Source: (StackOverflow)

How do you format date and time in Android?

How do you format correctly according to the device configuration a date and time when having year, month, day, hour and minute?


Source: (StackOverflow)

In Ruby on Rails, what's the difference between DateTime, Timestamp, Time and Date?

In my experience, getting dates/times right when programming is always fraught with danger and difficulity.

Ruby and Rails have always eluded me on this one, if only due to the overwhelming number of options; I never have any idea which I should pick.

When I'm using Rails and looking at ActiveRecord datatypes I can find the following

:datetime, :timestamp, :time, and :date

and have no idea what the differences are or where the gotchas lurk.

What's the difference? What do you use them for?

(P.S. I'm using Rails3)


Source: (StackOverflow)

How to convert Milliseconds to "X mins, x seconds" in Java?

I want to record the time using System.currentTimeMillis() when a user begins something in my program. When he finishes, I will subtract the current System.currentTimeMillis() from the start variable, and I want to show them the time elapsed using a human readable format such as "XX hours, XX mins, XX seconds" or even "XX mins, XX seconds" because its not likely to take someone an hour.

What's the best way to do this?


Source: (StackOverflow)

Java string to date conversion

Can somebody recommend the best way to convert a string in the format 'January 2, 2010' to a date in java? Ultimately, I want to break out the month, the day, and the year as integers so that I can use:

Date date = new Date();
date.setMonth()..
date.setYear()..
date.setDay()..
date.setlong currentTime = date.getTime();

to convert the date into time.


Source: (StackOverflow)

Get current time and date on Android

How can I get the current time and date in an Android app?


Source: (StackOverflow)

What do 'real', 'user' and 'sys' mean in the output of time(1)?

$ time foo
real        0m0.003s
user        0m0.000s
sys         0m0.004s

Which of these three is meaningful when benchmarking my app?


Source: (StackOverflow)

How to get current time in Python

What is the module/method used to get current time?


Source: (StackOverflow)

Should I use Java date and time classes or go with a 3rd party library like Joda Time?

I'm creating a web based system which will be used in countries from all over the world. One type of data which must be stored is dates and times.

What are the pros and cons of using the Java date and time classes compared to 3rd party libraries such as Joda time? I guess these third party libraries exist for a good reason, but I've never really compared them myself.


Source: (StackOverflow)

How to use timeit module

I understand the concept of what timeit does but I am not sure how to implement it in my code.

How can I compare two functions, say insertion_sort and tim_sort, with timeit?


Source: (StackOverflow)

System.currentTimeMillis() vs. new Date() vs. Calendar.getInstance().getTime()

In Java, what are the performance and resource implications of using

System.currentTimeMillis()

vs.

new Date()

vs.

Calendar.getInstance().getTime()

As I understand it, System.currentTimeMillis() is the most efficient. However, in most applications, that long value would need to be converted to a Date or some similar object to do anything meaningful to humans.


Source: (StackOverflow)