In Java, we can use System.currentTimeMillis() to get the current timestamp in Milliseconds since epoch time which is -

the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.

In C++ how to get the same thing?

Currently I am using this to get the current timestamp -

struct timeval tp;
gettimeofday(&tp, NULL);
long int ms = tp.tv_sec * 1000 + tp.tv_usec / 1000; //get current timestamp in milliseconds
cout << ms << endl;

This looks right or not?

Best Solutions is

If you have access to the C++ 11 libraries, check out the std::chrono library. You can use it to get the milliseconds since the Unix Epoch like this:

#include <chrono>// ...using namespace std::chrono;
milliseconds ms = duration_cast< milliseconds >(



I have a uri like which has an image


How to use this uri to get the image but it returns null, please tell me where i am wrong.

Bitmap bitmap = BitmapFactory.decodeFile(uri.getPath());

Simple way to do

This is a simple one line way to do it:

try {
URL url = new URL("http://....");
Bitmap image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
} catch(IOException e) {



Before, in an older version of express, I could do this:

express.createServer({key:'keyFile', cert:'certFile'});

However, in newer versions of express this no longer works:

var app = express();

Should I call app.use() to set the certs? If so how?

Try with the below solution

See the Express docs as well as the Node docs for https.createServer (which is what express recommends to use):

var privateKey = fs.readFileSync( 'privatekey.pem' );
var certificate = fs.readFileSync( 'certificate.pem' );
key: privateKey,
cert: certificate
}, app).listen(port);

Other options for createServer are at:

Read more answers from the programming Q&A website





Curated Solutions On Popular Questions — On All Programming Languages, Cloud Computing, Tools etc