Example usage for java.time ZoneOffset ofHoursMinutes

List of usage examples for java.time ZoneOffset ofHoursMinutes

Introduction

In this page you can find the example usage for java.time ZoneOffset ofHoursMinutes.

Prototype

public static ZoneOffset ofHoursMinutes(int hours, int minutes) 

Source Link

Document

Obtains an instance of ZoneOffset using an offset in hours and minutes.

Usage

From source file:Main.java

public static void main(String[] args) {
    ZoneOffset t = ZoneOffset.ofHoursMinutes(1, 20);
    System.out.println(t);
}

From source file:Main.java

public static void main(String[] args) {
    ZoneOffset zoneOffset1 = ZoneOffset.ofHours(-1);
    System.out.println(zoneOffset1);
    ZoneOffset zoneOffset2 = ZoneOffset.ofHoursMinutes(6, 30);
    System.out.println(zoneOffset2);
    ZoneOffset zoneOffset3 = ZoneOffset.ofHoursMinutesSeconds(9, 30, 45);
    System.out.println(zoneOffset3);
}

From source file:Main.java

public static void main(String[] args) {
    // current offset time
    OffsetTime ot1 = OffsetTime.now();
    System.out.println("Current  offset  time: " + ot1);

    // a zone offset +01:30
    ZoneOffset offset = ZoneOffset.ofHoursMinutes(1, 30);

    OffsetTime offsetTime = OffsetTime.of(16, 40, 28, 0, offset);
    System.out.println(offsetTime);

}

From source file:net.consulion.jeotag.PhotoLoader.java

private static Instant getTimeTaken(final TiffImageMetadata exif, final File file) {
    Instant instant = null;//from   w w w  .ja va2 s .c o  m
    if (exif != null) {
        try {
            final String[] dateTimeOriginal = exif.getFieldValue(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
            if (dateTimeOriginal.length == 1
                    && dateTimeOriginal[0].matches("\\d{4}\\:\\d{2}:\\d{2}\\s\\d{2}:\\d{2}:\\d{2}")) {
                final String[] split = dateTimeOriginal[0].split("\\s");
                final String dateString = split[0];
                final String timeString = split[1];
                final String[] dateSplit = dateString.split("\\:");
                final int year = Integer.parseInt(dateSplit[0]);
                final int month = Integer.parseInt(dateSplit[1]);
                final int day = Integer.parseInt(dateSplit[2]);
                final String[] timeSplit = timeString.split("\\:");
                final int hour = Integer.parseInt(timeSplit[0]);
                final int minute = Integer.parseInt(timeSplit[1]);
                final int second = Integer.parseInt(timeSplit[2]);
                final LocalDateTime ldt = LocalDateTime.of(year, month, day, hour, minute, second);
                instant = ldt.toInstant(ZoneOffset.ofHoursMinutes(0, 0));
            } else {
                log(Level.WARNING, String.format("unknown date format in file %s", file.getPath()));
            }
        } catch (ImageReadException ex) {
            Logger.getLogger(PhotoLoader.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    return instant;
}