Example usage for java.util TimeZone getDefault

List of usage examples for java.util TimeZone getDefault

Introduction

In this page you can find the example usage for java.util TimeZone getDefault.

Prototype

public static TimeZone getDefault() 

Source Link

Document

Gets the default TimeZone of the Java virtual machine.

Usage

From source file:com.mousebird.maply.MaplyStarModel.java

public static double getJulianDateDouble(long millis) {

    TimeZone timeZone = TimeZone.getDefault();

    millis += timeZone.getOffset(millis);
    int integer = (int) (millis / MILLIS_IN_DAY);
    double fraction = (double) (millis % MILLIS_IN_DAY) / MILLIS_IN_DAY;
    integer += getInteger(2440587, 0.5);
    fraction += getFraction(2451910, 0.5);
    return (double) integer + fraction;
}

From source file:org.jfree.data.time.junit.MillisecondTest.java

/**
 * Some checks for the getFirstMillisecond() method.
 *///from w  w w .jav  a2 s .  c o  m
public void testGetFirstMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Millisecond m = new Millisecond(500, 15, 43, 15, 1, 4, 2006);
    assertEquals(1143902595500L, m.getFirstMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}

From source file:org.jfree.data.time.MonthTest.java

/**
 * Some checks for the getFirstMillisecond() method.
 *///from ww w.  j  av  a 2 s  . com
@Test
public void testGetFirstMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Month m = new Month(3, 1970);
    assertEquals(5094000000L, m.getFirstMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}

From source file:io.ionic.links.IonicDeeplink.java

private String getTimeZoneID() {
    TimeZone tz = TimeZone.getDefault();
    return (tz.getID());
}

From source file:fr.pilato.elasticsearch.crawler.fs.framework.FsCrawlerUtil.java

public static Date localDateTimeToDate(LocalDateTime ldt) {
    return Date.from(ldt.atZone(TimeZone.getDefault().toZoneId()).toInstant());
}

From source file:edu.dlnu.liuwenpeng.Time.TimeSeriesCollection.java

/**    
* Constructs a dataset containing a single series (more can be added),    
* tied to a specific timezone.    //from  w  ww  .j a v a2 s  .  c o  m
*    
* @param series  a series to add to the collection (<code>null</code>     
*                permitted).    
* @param zone  the timezone (<code>null</code> permitted, will use     
*              <code>TimeZone.getDefault()</code> in that case).    
*/
public TimeSeriesCollection(TimeSeries series, TimeZone zone) {

    if (zone == null) {
        zone = TimeZone.getDefault();
    }
    this.workingCalendar = Calendar.getInstance(zone);
    this.data = new ArrayList();
    if (series != null) {
        this.data.add(series);
        series.addChangeListener(this);
    }
    this.xPosition = TimePeriodAnchor.START;
    this.domainIsPointsInTime = true;

}

From source file:org.jfree.data.time.junit.HourTest.java

/**
     * Some checks for the getFirstMillisecond() method.
     *///ww  w.  j a  v a2 s . c o  m
public void testGetFirstMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Hour h = new Hour(15, 1, 4, 2006);
    assertEquals(1143900000000L, h.getFirstMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}

From source file:org.jfree.data.time.DayTest.java

/**
 * Some checks for the getFirstMillisecond() method.
 *//* w w w.java 2s .  c  o m*/
@Test
public void testGetFirstMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Day d = new Day(1, 3, 1970);
    assertEquals(5094000000L, d.getFirstMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}

From source file:org.opendatakit.tables.utils.WebViewUtil.java

/**
 * Turn the map into a {@link ContentValues} object. Returns null if any of
 * the element keys do not exist in the table, or if the value cannot be
 * parsed to the type of the column./*from   w  ww. j  a  va  2  s .  c o m*/
 *
 * @param context
 * @param appName
 * @param tableId
 * @param orderedDefns
 * @param elementKeyToValue
 * @return
 * @throws ServicesAvailabilityException
 */
public static ContentValues getContentValuesFromMap(Context context, String appName, String tableId,
        OrderedColumns orderedDefns, Map<String, String> elementKeyToValue)
        throws ServicesAvailabilityException {
    // Note that we're not currently
    // going to handle complex types or those that map to a json value. We
    // could, but we'd probably have to have a known entity do the conversions
    // for us somehow on the js side, rather than expect the caller to craft up
    // whatever format we've landed on for pictures.
    // This will contain the values we're going to insert into the database.
    ContentValues result = new ContentValues();
    // TODO: respect locale and timezone. Getting this structure from other
    // places it is used.

    DateUtils dataUtil = new DateUtils(Locale.ENGLISH, TimeZone.getDefault());
    for (Map.Entry<String, String> entry : elementKeyToValue.entrySet()) {
        String elementKey = entry.getKey();
        String rawValue = entry.getValue();
        // Get the column so we know what type we need to handle.
        ColumnDefinition columnDefn = orderedDefns.find(elementKey);
        if (columnDefn == null) {
            // uh oh, no column for the given id. problem on the part of the caller
            WebLogger.getLogger(appName).e(TAG,
                    "[addRow] could not find column for element key: " + elementKey);
            return null;
        }
        ElementType columnType = columnDefn.getType();
        boolean parsedSuccessfully = addValueToContentValues(context, appName, tableId, dataUtil, columnDefn,
                rawValue, result);
        if (!parsedSuccessfully) {
            WebLogger.getLogger(appName).e(TAG,
                    "[addRow] could not parse value: " + rawValue + " for column type " + columnType);
            return null;
        }
    }
    return result;
}

From source file:com.bdb.weather.display.summary.HighLowMedianTempPanel.java

/**
 * Load the data into the graph and the JTable.
 * /*from   w ww. j a  v a  2 s.  c  o  m*/
 * @param summaryList The list of summary records to be loaded
 * @param lowDataset The graph's dataset that holds the low temperature values
 * @param highDataset The graph's dataset that holds the high temperature values
 * @param meanDataset The graph's dataset that holds the mean temperature values
 * @param tableModel The JTable model to be loaded
 * @param averagesCollection The averages to load into the graph and table
 */
private void loadDataSeries(List<SummaryRecord> summaryList, TimeSeriesCollection lowDataset,
        TimeSeriesCollection highDataset, TimeSeriesCollection meanDataset,
        WeatherAverages averagesCollection) {

    TimeSeries highSeries = new TimeSeries("High");
    TimeSeries lowSeries = new TimeSeries("Low");
    TimeSeries meanSeries = new TimeSeries("Mean");
    TimeSeries averageLowSeries = new TimeSeries("Average Low");
    TimeSeries averageHighSeries = new TimeSeries("Average High");
    TimeSeries averageMeanSeries = new TimeSeries("Average Mean");

    int n = 0;

    for (SummaryRecord r : summaryList) {
        //tableModel.setValueAt(dateFormat.format(r.getDate()), n, DATE_COLUMN);

        RegularTimePeriod p = RegularTimePeriod.createInstance(interval.getFreeChartClass(),
                TimeUtils.localDateTimeToDate(r.getDate().atStartOfDay()), TimeZone.getDefault());

        WeatherAverage averages = averagesCollection.getAverage(r.getDate());
        averageLowSeries.add(p, averages.getLowTemperature().get());
        averageHighSeries.add(p, averages.getHighTemperature().get());
        averageMeanSeries.add(p, averages.getMeanTemperature().get());
        //tableModel.setValueAt(averages.getHighTemperature().toString(), n, AVG_HIGH_TEMP_COLUMN);
        //tableModel.setValueAt(averages.getLowTemperature().toString(), n, AVG_LOW_TEMP_COLUMN);
        //tableModel.setValueAt(averages.getMeanTemperature().toString(), n, AVG_MEAN_TEMP_COLUMN);

        Temperature t = supporter.retrieveHighOutdoorTemperature(r);

        if (t != null) {
            highSeries.add(p, t.get());
            //tableModel.setValueAt(t.toString(), n, HIGH_TEMP_COLUMN);
        }

        t = supporter.retrieveLowOutdoorTemperature(r);

        if (t != null) {
            lowSeries.add(p, t.get());
            //tableModel.setValueAt(t.toString(), n, LOW_TEMP_COLUMN);
        }

        t = supporter.retrieveAvgOutdoorTemperature(r);

        if (t != null) {
            meanSeries.add(p, t.get());
            //tableModel.setValueAt(t.toString(), n, MEDIAN_TEMP_COLUMN);
        }

        n++;
    }

    highDataset.addSeries(highSeries);
    highDataset.addSeries(averageHighSeries);

    lowDataset.addSeries(lowSeries);
    lowDataset.addSeries(averageLowSeries);

    meanDataset.addSeries(meanSeries);
    meanDataset.addSeries(averageMeanSeries);

    diffRenderer.setSeriesPaint(ACTUAL_SERIES, Color.RED);
    diffRenderer.setSeriesPaint(AVERAGE_SERIES, Color.RED.darker());

    diffRenderer.setSeriesPaint(ACTUAL_SERIES, Color.BLUE);
    diffRenderer.setSeriesPaint(AVERAGE_SERIES, Color.BLUE.darker());

    diffRenderer.setSeriesPaint(ACTUAL_SERIES, Color.GREEN);
    diffRenderer.setSeriesPaint(AVERAGE_SERIES, Color.GREEN.darker());
}