Question: I am trying to parse the following date in Jenkins `2021-10-14T18:12:20.578+00:00` however, I am getting the error `Unparseable date: "2020-01-01T10:10:20.578+00:00"`

This is my code, not sure what I am doing wrong:

```
Date myDate= new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").parse("2020-01-01T10:10:20.578+00:00");

```

**EDIT:**

Thanks to Kaus, I found that my date is not formatted properly and should be `2020-01-01T10:10:20.578GMT+00:00`

I'm getting this date from some other files. I can replace + with GMT+ as follow:

```
def myDate = "2020-01-01T10:10:20.578+00:00"
myDate = myDate.replaceAll("\\+", "GMT\\+")

```

How can I do the same thing if my date is `"2020-01-01T10:10:20.578-06:00"`
The following is replacing every "-"

```
def myDate = "2020-01-01T10:10:20.578-06:00"
myDate = myDate.replaceAll("\\+", "GMT\\+").replaceAll("\\-", "GMT\\-")

```

Output: `"2020GMT-01GMT-01T10:10:20.578GMT-06:00"`

Answer: 
you can try this code,

```
    select 
    fname,
    abs(sum(amount2)) amount
from
(
WITH
student(fname,amount,vdate) AS (
            SELECT 'Josh' ,15, to_date('01102017','ddmmyyyy')  from dual
  UNION ALL SELECT 'Steve',25,  to_date('01102017','ddmmyyyy') from dual
  UNION ALL SELECT 'Josh' ,40   ,to_date('01102019','ddmmyyyy')from dual
)

select 
    h.fname,
    h.amount,
    decode((ROW_NUMBER() OVER(PARTITION BY fname order by vdate desc)),1,amount,amount* -1) amount2

    from student h
)
group by 
    fname
    ;

```

I assume that you get the greater amount value of the person and substract other values, you can select the bigger date instead by modifying the order by clause in the partition window i. e.

```
decode((ROW_NUMBER() OVER(PARTITION BY fname order by vdate desc)),1,amount,amount * -1) amount2

```
You can try this (I don't know what sense it makes ...):
Count the number of rows found until now per `fname` ("name" is a reserved word and I don't use it). And if the row number obtained this way is odd, then use the negative amount, else the positive amount.
Finally, run a sum over these positive/negative rows.

```
WITH
indata(fname,amount) AS (
            SELECT 'Josh' ,15 
  UNION ALL SELECT 'Steve',25
  UNION ALL SELECT 'Josh' ,40 
)
,
alternate AS (
  SELECT
    fname
  , CASE ROW_NUMBER() OVER(PARTITION BY fname) % 2 
      WHEN 1 THEN amount * -1 -- when odd then negative
      ELSE        amount      -- else positive
    END  AS amount
  FROM indata
)
SELECT
  fname
, ABS(SUM(amount)) AS amount -- absolute value
FROM alternate
GROUP BY fname;
-- out  fname | amount 
-- out -------+--------
-- out  Josh  |     25
-- out  Steve |     25

```