Example usage for java.time ZoneId systemDefault

List of usage examples for java.time ZoneId systemDefault

Introduction

In this page you can find the example usage for java.time ZoneId systemDefault.

Prototype

public static ZoneId systemDefault() 

Source Link

Document

Gets the system default time-zone.

Usage

From source file:com.hengyi.japp.tools.DateTimeUtil.java

public static LocalDateTime toLocalDateTime(Date date) {
    return date == null ? null : LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
}

From source file:dragonrental.backend.DbConfig.java

public DragonManager dragonManager() {
    DragonManagerImpl dManager = new DragonManagerImpl(Clock.system(ZoneId.systemDefault()));
    dManager.setDataSource(ds);//from  www.java  2 s. c  om
    return dManager;
}

From source file:eu.off.db.entity.MemberTest.java

@Test
public void BuildFullMember() {

    LocalDateTime dateTime = LocalDateTime.of(1978, Month.APRIL, 4, 0, 0);
    Date birthday = Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());

    Member aMember = new MemberBuilder(LAST_NAME, FIRST_NAME, STREET, ZIP_CODE, PLACE, COUNTRY, birthday,
            GENDER, NATIONALITY).email(EMAIL).phone(PHONE).portablePhone(PORTABLE_PHONE).memberSince(birthday)
                    .licenseSince(birthday).build();

    assertThat(aMember.getEmail().equals(EMAIL));
    assertThat(aMember.getPhone().equals(PHONE));
    assertThat(aMember.getPortablePhone().equals(PORTABLE_PHONE));
    assertThat(aMember.getMemberSince().equals(birthday));
    assertThat(aMember.getLicenseSince().equals(birthday));

}

From source file:Graphite.java

public Graphite(String graphiteUrl, String user, String password, SimulationContext stats, File outputDirectory,
        ZoneId zoneId) {//from w  w w  . j a  v  a2s  .  c o m
    this.dashboardUrl = graphiteUrl;
    baseUrl = Utils.getBaseUrl(graphiteUrl);
    if (zoneId == null) {
        this.zoneId = ZoneId.systemDefault();
    } else {
        this.zoneId = zoneId;
    }
    this.from = getDateAsString(stats.simStat.start - 30000L);
    this.until = getDateAsString(stats.simStat.end + 60000L); // add one more minute to prevent empty chart
    this.outputDirectory = outputDirectory;
    this.user = user;
    this.password = password;
    Utils.setBasicAuth(user, password);
    parseDashboard();
    downloadImages();
}

From source file:org.lizardirc.beancounter.commands.earthquake.GeoJsonFeatureProperty.java

public ZonedDateTime getEventTime() {
    return ZonedDateTime.ofInstant(Instant.ofEpochMilli(eventTime), ZoneId.systemDefault());
}

From source file:Main.java

public static String getStringFromMillis(final Number millis) {
    return FORMATTER
            .format(LocalDateTime.ofInstant(Instant.ofEpochMilli(millis.longValue()), ZoneId.systemDefault()));
}

From source file:org.zephyrsoft.sdb2.Start.java

private Start(String[] args) {
    LOG.debug("starting application");

    // parse command line arguments
    CmdLineParser parser = new CmdLineParser(options);
    parser.setUsageWidth(80);/* w  w w  . jav a 2 s  . c om*/
    try {
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        options.setHelp(true);
    }

    if (options.isHelp()) {
        System.err.println("The available options are:");
        parser.printUsage(System.err);
    } else {
        try {
            // set encoding to UTF-8 (the cache has to be reset to make the new definition effective)
            System.setProperty("file.encoding", "UTF-8");
            Field charset = Charset.class.getDeclaredField("defaultCharset");
            charset.setAccessible(true);
            charset.set(null, null);

            LOG.info("default time zone is {}", ZoneId.systemDefault().getId());

            LOG.info("loading application context");
            @SuppressWarnings("resource")
            AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
            context.register(SpringConfiguration.class);
            context.refresh();

            context.getAutowireCapableBeanFactory().autowireBean(this);
            mainController.loadSongs(options.getSongsFile());

            mainWindow.startup();
        } catch (Exception e) {
            LOG.error("problem while starting up the application", e);
            System.exit(-1);
        }
    }
}

From source file:daylightchart.daylightchart.calculation.RiseSetUtility.java

/**
 * Calculator for sunrise and sunset times for a year.
 *
 * @param location/*from   w ww .  ja va 2 s  . c  o m*/
 *        Location
 * @param year
 *        Year
 * @param options
 *        Options
 * @return Full years sunset and sunrise times for a location
 */
public static RiseSetYearData createRiseSetYear(final Location location, final int year,
        final Options options) {
    final TimeZoneOption timeZoneOption = options.getTimeZoneOption();
    final ZoneId zoneId;
    if (location != null) {
        final String timeZoneId;
        if (timeZoneOption != null && timeZoneOption == TimeZoneOption.USE_TIME_ZONE) {
            timeZoneId = location.getTimeZoneId();
        } else {
            timeZoneId = DefaultTimezones.createGMTTimeZoneId(location.getPointLocation().getLongitude());
        }
        zoneId = ZoneId.of(timeZoneId);
    } else {
        zoneId = ZoneId.systemDefault();
    }
    final boolean timeZoneUsesDaylightTime = !zoneId.getRules().getTransitionRules().isEmpty();
    final boolean useDaylightTime = timeZoneUsesDaylightTime && timeZoneOption != TimeZoneOption.USE_LOCAL_TIME;
    boolean wasDaylightSavings = false;

    final TwilightType twilight = options.getTwilightType();
    final RiseSetYearData riseSetYear = new RiseSetYearData(location, twilight, year);
    riseSetYear.setUsesDaylightTime(useDaylightTime);
    for (final LocalDate date : getYearsDates(year)) {
        final boolean inDaylightSavings = zoneId.getRules()
                .isDaylightSavings(date.atStartOfDay().atZone(zoneId).toInstant());
        if (wasDaylightSavings != inDaylightSavings) {
            if (!wasDaylightSavings) {
                riseSetYear.setDstStart(date);
            } else {
                riseSetYear.setDstEnd(date);
            }
        }
        wasDaylightSavings = inDaylightSavings;

        final RawRiseSet riseSet = calculateRiseSet(location, date, useDaylightTime, inDaylightSavings,
                TwilightType.NO);
        riseSetYear.addRiseSet(riseSet);

        if (twilight != null) {
            final RawRiseSet twilights = calculateRiseSet(location, date, useDaylightTime, inDaylightSavings,
                    twilight);
            riseSetYear.addTwilight(twilights);
        }

    }

    // Create band for twilight, clock-shift taken into account
    createBands(riseSetYear, DaylightBandType.twilight);
    // Create band, clock-shift taken into account
    createBands(riseSetYear, DaylightBandType.with_clock_shift);
    // Create band, without clock shift
    createBands(riseSetYear, DaylightBandType.without_clock_shift);

    return riseSetYear;

}

From source file:org.apdplat.superword.system.AntiRobotFilter.java

public static void main(String[] args) {
    LocalDateTime timePoint = LocalDateTime.now().minusDays(1);
    String date = SIMPLE_DATE_FORMAT.format(Date.from(timePoint.atZone(ZoneId.systemDefault()).toInstant()));
    System.out.println(date);//w  ww  .  j  av a2  s  .  c o  m
}

From source file:org.lizardirc.beancounter.commands.earthquake.GeoJsonFeatureProperty.java

public ZonedDateTime getUpdatedTime() {
    return ZonedDateTime.ofInstant(Instant.ofEpochMilli(updated), ZoneId.systemDefault());
}