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 millisecondscout << 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 >(
system_clock::now().time_since_epoch()
I have a uri like which has an image
file:///mnt/...............
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) {
System.out.println(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…