Skip to content
Advertisement

reading a whole date and time with spaces in a file

this question may have been asked before but didn’t find any clue for my problem here,

here is my problem : I have a file that is like this :

abc fg Sat Jan 08 19:06:21 IST 2022 4 4.0

here is my code that reads from the file :

JavaScript

now i want each “token.nextToken();“` inside the ShortDeliveries to be like this:

JavaScript

Advertisement

Answer

In case you know the date will always start with the day of week (e.g. Sat, Sun…), you can create a method to check if the current token is a known day. In case this is a week day, collect the following 6 tokens (or whatever tokens count you need to form a valid date) and send them together as String to your convert method.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement