i have convert datetime 1 format in java. here period im starting with:
2001-01-01t01:00z/2002-02-02t02:00z   and here result need end with:
2002-02-02t02:00:00   so need second part of period , need add :00 seconds end , remove z.
im not familiar date formats. 1 of these standard format? can use kind of library read , convert these datetimes?
tl;dr
interval.parse( input )          .getend()         .atoffset( zoneoffset.utc )          .format(             datetimeformatter.iso_local_date_time          )   interval
  your input string period on standard iso 8601 format. represents pair of moments, z on end short zulu , means utc. slash character separates start , stop. 
parse interval class found in threeten-extra project. 
interval interval = interval.parse( input ) ;   instant
  extract stop moment.
instant instant = interval.getend() ;   offsetdatetime
  i suspect should working objects instant rather manipulating string. if insist, generating formatted string, convert instant offsetdatetime. 
offsetdatetime odt = instant.atoffset( zoneoffset.utc ) ;   also, bad idea drop offset/zone indicator such z. resulting string becomes ambiguous meaning, no longer representing specific moment on timeline. if insist, there predefined matter.
string output = odt.format( datetimeformatter.iso_local_date_time ) ;      
Comments
Post a Comment