Android Kotlin Convert Timestamp Milliseconds to Seconds and Vise-Versa

masterjosh
by
masterjosh
Jan 10, 2019
Android Kotlin Convert Timestamp Milliseconds to Seconds and Vise-Versa

Hi Dev,

this pretty little snippet am about to share, will allow you to convert php timestamp seconds to Java milliseconds and Java milliseconds to seconds format...

Milliseconds to Seconds

Fun/method code named timestampToSec


fun timestampToSec(time: Long): Long {
        return if (time < 1000000000000L) {
            // if timestamp given in seconds, convert to millis
            time
        } else {
            time / 1000
        }
    }

Seconds to Milliseconds

Fun/method code named timestampToMilli


fun timestampToMilli(time: Long): Long {
        return if (time < 1000000000000L) {
            // if timestamp given in seconds, convert to millis
            time * 1000
        } else {
            time
        }
    }

are you have any problem using this code ?

i will be happy to help via comment section 

Happy Coding!




Comments (16434)
Keljarf
by
Keljarf
Apr 27, 2019

Precio Cialis 5 Mg En Farmacia Espana Wellbutrin Online Prescriptions <a href=http://cialionline.com>cialis</a> Bactrim Ds Without An Rx Cheap Cialis Online Pharmacy

Keljarf
by
Keljarf
May 11, 2019

Purchase Of Viagra <a href=http://cialicheap.com>cialis 40 mg</a> Leukemia By Antibiotic Amoxicillin

viagra online
by
viagra online
May 29, 2019

The purchase by a dentist or a dental lab owner of raw materials that will or Air Force Manuals) or application and testing fees. <a href="https://viagraoktobuy.com/">buy viagra online</a> It was then repurposed as a libido enhancer, and the FDA rejected the drug twice before, out of concerns that flibanserin's benefits to the libido (about half an additional sexual encounter each month above a placebo for a small subset of users) didn??™t outweigh the potentially dangerous risks.

canadian pharmacy viagra
by
canadian pharmacy viagra
Jun 05, 2019

Levitra works faster than Viagra side effects significantly less. <a href="https://viagraoktobuy.com/">order viagra online</a> Those we might have to get up for a new account and purchase a subscription or inquire.

Lescown
by
Lescown
Jul 30, 2019

Keflex Stomach Viagra Kopfschmerzen Vermeiden Prednisone Orders Canada <a href=http://truthaboutstaininggrid.com></a> Buy Levitra 10mg Propecia Vente Ligne

Lescown
by
Lescown
Aug 03, 2019

Viagran Sin Receta En Us <a href=http://curerxfor.com>viagra</a> Order Bulk Cialis

Lescown
by
Lescown
Aug 07, 2019

Cialis Generika Aus Deutschland <a href=http://genericviabuy.com>viagra</a> Cialisis 20mg Online Purchase

sxuuwx
by
sxuuwx
Aug 21, 2019

buy viagra alternative online http://canadianonlinebuy.com

nvfkmq
by
nvfkmq
Aug 26, 2019

forum viagra generico http://canadianonlinebuy.com

qlimzn
by
qlimzn
Sep 01, 2019

avanafil vs levitra http://levitrany.com

<a href="http://levitrany.com/">generic levitra uk</a>

Add Comment