How to I convert long (currentTimeInMillis) to UTC timestamp?

My client is sending me Long which could be thought as

scala> System.currentTimeMillis
res3: Long = 1441056836609


How do I convert that into UTC timeStamp?

On Server, we are using Java 8


This is what I am doing

I am using Joda-Time and doing


On client I see it as

Wed, 02 Sep 2015 20:57:34 GMT

and on server I see it as


P.S. Don’t compare values, they are copied differently, the format is what I wanted to share


Android RecyclerView overlap items (Card stacks)

How can I overlap items in RecyclerView?
Like stacking cards.

Thanks in advance.


You have to write your own LayoutManager or extends LinearLayoutManager


How to add tooltip to table header

I’m using jQuery DataTables and I have been trying to add tooltips to the Header column of my datatables for the past 2 days to no avail.

I have used the example on the datatables website where tooltips were added to the row data, but that didn’t work. I only see one tooltip, and it does not even get the title of the column.

Below is the code I have so far.

if (oTable != null) {
} else {

    oTable = $('#caseDataTable').dataTable({
        "bDestroy": true,
        "aaData": columnData,
        "aoColumnDefs": columnNames,
        bFilter: true,
        bAutoWidth: true,
        autoWidth: true,
        "responsive": true,
        dom: 'Bfltip',
        buttons: [
                extend: 'colvis',
                postfixButtons: ['colvisRestore'],
                collectionLayout: 'fixed two-column'
        "fnDrawCallback": function() {
            if (typeof oTable != 'undefined') {

            $('#caseDataTable thead tr').each(function () {
                var sTitle;
                var nTds = $('td', this);
                var columnTitle= $(nTds[0]).text();

                 this.setAttribute('title', columnTitle);

            /* Apply the tooltips */
            $('#caseDataTable thead tr[title]').tooltip({
                "delay": 0,
                "track": true,
                "fade": 250



There are multiple issues with your code:

  • You have incorrect CSS selectors, you should be targeting th elements and not tr.
  • initComplete is a proper place to do this since you only need to do it once.


My example below is for Bootstrap Tooltip. Adjust to your tooltip plugin accordingly.

$(document).ready(function() {  
    var table = $('#example').DataTable( {     
        "ajax": '',
        "initComplete": function(settings){
            $('#example thead th').each(function () {
               var $td = $(this);
               $td.attr('title', $td.text());

            /* Apply the tooltips */
            $('#example thead th[title]').tooltip(
               "container": 'body'
<link href="//" rel="stylesheet" />
<script src=""></script> 
<script src="//"></script>

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="">

<!-- Latest compiled and minified JavaScript -->
<script src=""></script> 

<table id="example" class="display">
        <th>Start Date</th>

        <th>Start Date</th>      

Meteor wrapAsync executes synchronously but never returns

I’m trying to wrap a function from a node package with wrapAsync.

filepicker = new Filepicker('API Key') 
filepickerStatSync = Meteor.wrapAsync(filepicker.stat, filepicker)
result = filepickerStatSync(url);

The stat function is below.

Everything seem to work fine… the request call responds with the correct result, the final callback is called, the whole thing executes synchronously / yields correctly as far as I can tell… but the sync call never returns and console.log(‘after’) is never hit.

I don’t think I made the same mistake as happened in this question because my function has a callback as the last parameter.

I also don’t think the solution is in this question because the wrapped function does end with calling the callback with error and result, which is supposedly what Meteor.wrapAsync is looking for in a signature.

Filepicker.prototype.stat = function(url, options, callback) {
    callback = callback || function(){};
    if(!options) {
        options = {};
    if(!url) {
        callback(new Error('Error: no url given'));
        method: 'GET',
        url: url+'/metadata?',
        form: {
            size: options.size || true,
            mimetype: options.mimetype || true,
            filename: options.filename || true,
            width: options.width || true,
            height: options.height || true,
            writeable: options.writeable || true,
            md5: options.md5 || true,
            path: options.path || true,
            container: options.container || true,
            security: || {}
    }, function(err, res, body) {
        console.log('err = '+err);
        console.log('res = '+res);
        console.log('body = '+body);
        if(err) {
        var returnJson;
            try {
                returnJson = JSON.parse(body);
             } catch(e) {
                callback(new Error('Unknown response'), null, body);
        } else {
            returnJson = body;
        callback(null, returnJson);


The function you are wrapping takes three arguments, but you are only providing two: url, and (implicitly) the callback function (I’ll call it cb). So internally, what will get executed is Filepicker.prototype.stat(url, cb), i.e., the callback function cb will get interpreted as the options rather than the callback, and callback will be set to an empty function. So the callback of wrapAsync is never called, because the callback chain was broken.

This should work:

result = filepickerStatSync(url, {});

Making N sequential api calls using RxJava and Retrofit

I have a list of files that I’d like to upload to the backend from an Android device. Due to memory constraints, I’d like to make the second API call only after the first finished, the third after the second finished, and so on.

I wrote something like

private Observable<Integer> uploadFiles(List<File> files) {
        return Observable.create(subscriber -> {
            for (int i = 0, size = files.size(); i < size; i++) {
                UploadModel uploadModel = new UploadModel(files.get(0));
                int uploadResult = retrofitApi.uploadSynchronously(uploadModel);

But I feel like this might be going against the spirit of Rx, and the saying is if you’re using Observable.create, you’re probably doing it wrong… Is this a reasonable approach? Is there a better way to achieve this with Retrofit’s RxJava integration?


Naively, I would do that (it does not work, though, see below):

return Observable.from(files).concatMap(file -> retrofitApi.upload(uploadModel));

Now the issue is that there is no way to tell retrofit to use only one thread for those calls.

reduce, however, passes the result of one function call to the next, along with the next emitted value from the original observable. That would work, but the function passed to reduce needs to be synchronous. Not good.

Another approach would be to modify the observable recursively:

void getNextFile(int i) {
    return retrofit.upload(i).
        onNext(result -> getNextFile(i + 1));

roughly. But I am not sure how to clean it to make it more readable.

The cleanest I would think would be something like:

Observable.from(files).map(file -> retrofitApi.uploadSynchronously(new UploadModel(file)));
Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..