Java Date Format Change convertIso8601FormatToArsTimeOfDay(String timeOfDayString)

Here you can find the source of convertIso8601FormatToArsTimeOfDay(String timeOfDayString)

Description

Converts a string in ISO8601 Format into the string corresponding to an Ars internal time of day representation

License

BSD License

Declaration

public static String convertIso8601FormatToArsTimeOfDay(String timeOfDayString) throws ParseException 

Method Source Code

//package com.java2s;
//License from project: BSD License 

import java.text.ParseException;

public class Main {
    /** Converts a string in ISO8601 Format into the string corresponding to an Ars internal time of day representation */
    public static String convertIso8601FormatToArsTimeOfDay(String timeOfDayString) throws ParseException {
        int hours, minutes, seconds;
        int total = 0;

        try {// w w  w. j  av  a2  s.c  om
            hours = Integer.parseInt(timeOfDayString.substring(0, 2));
        } catch (NumberFormatException e) {
            throw new ParseException("Unparseable dime: " + timeOfDayString, 0);
        }

        try {
            minutes = Integer.parseInt(timeOfDayString.substring(3, 5));
        } catch (NumberFormatException e) {
            throw new ParseException("Unparseable dime: " + timeOfDayString, 3);
        }

        try {
            seconds = Integer.parseInt(timeOfDayString.substring(6));
        } catch (NumberFormatException e) {
            throw new ParseException("Unparseable dime: " + timeOfDayString, 6);
        }

        total = hours * 3600 + minutes * 60 + seconds;

        return String.valueOf(total);
    }
}

Related

  1. convertDateFromTo(String stringDate, String patternToUse, TimeZone timezoneIn, TimeZone timezoneOut)
  2. convertDateStringToString(String dateString, String format)
  3. convertDateStringToString(String strDate, String currentFormat, String parseFormat)
  4. convertDatetimeFormat(Date tar_date, String date_format)
  5. convertIso8601FormatToArsTime(String timeString)
  6. convertISO8610ToCalendar(String iso8601string)
  7. convertTimeStringToTimestamp(String timeString, String timeFormat)