How to format Date-Time to yyyy-MM-dd'T'HH:mmX i.e 2023-04-19T07:00Z

149 Views Asked by At

we are currently using private final static String EDX_HOURLY_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss Z"; which gives the output as 2023-06-15T22:26:02 +0000 but we want to change the format to 2023-04-19T07:00Z. I tried to change this format from private final static String EDX_HOURLY_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss Z"; to private final static String EDX_HOURLY_DATE_FORMAT = "yyyy-MM-dd'T'HH:mmX"; but it is not working for me. below is how the date is getting converted

private final static String EDX_HOURLY_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss Z";

java.time.format.DateTimeFormatter standardDateFormat =         java.time.format.DateTimeFormatter.ofPattern(dateFormat);
    DateTimeFormatter dtf = DateTimeFormat.forPattern(dateFormat);
    ZonedDateTime date = ZonedDateTime.now(); 
    String currentTimeStr = standardDateFormat.format(date);
    DateTime jodatime = dtf.parseDateTime(currentTimeStr); 
    IonList dataSetKeyIonList = new KeyBuilder()
            .addString(**currentTimeStr**) // "date"
            .asList();

Output is : 2023-06-15T22:26:02 +0000

0

There are 0 best solutions below