Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

15
LINES

< > BotCompany Repo | #1002956 // toLong - convert to long with default 0

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (10068L/55K).

static long toLong(O o) {
  if (o instanceof Number)
    ret ((Number) o).longValue();
  if (o instanceof S)
    ret parseLong((S) o);
  ret 0;
}

static long toLong(Timestamp ts) {
  ret ts == null ? 0 : ts.unixDate();
}

static long toLong(Date d) {
  ret d == null ? 0 : d.getTime();
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney

No comments. add comment

Snippet ID: #1002956
Snippet name: toLong - convert to long with default 0
Eternal ID of this version: #1002956/3
Text MD5: f7680d72a89dc09fca7041b0b138002e
Transpilation MD5: 70f94a29e43d49ab9d9dd2ea35de3b83
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-01-23 18:56:22
Source code size: 302 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 782 / 919
Version history: 2 change(s)
Referenced in: [show references]