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

8
LINES

< > BotCompany Repo | #1036510 // parseWithDateFormats - try all formats until one works

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

Libraryless. Click here for Pure Java version (9947L/54K).

static long parseWithDateFormats(S s, SimpleDateFormat... formats) ctex {
  if (empty(s)) ret 0;
  fOr (format : formats) try {
    ret format.parse(s).getTime();
  } catch e {}
  
  fail("Can't parse date", s, "tried formats", formats);
}

Author comment

Began life as a copy of #1014580

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1036510
Snippet name: parseWithDateFormats - try all formats until one works
Eternal ID of this version: #1036510/1
Text MD5: ff4c46137ad0558b107f76629c53c329
Transpilation MD5: 9e5a993449e850dfbc95f08f50830bbb
Author: stefan
Category: javax / calendar
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-01-19 15:05:17
Source code size: 246 bytes / 8 lines
Pitched / IR pitched: No / No
Views / Downloads: 141 / 193
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)