Posts

Showing posts with the label date

setOnAction restrictions and datepicker class

Image
Clash Royale CLAN TAG #URR8PPP setOnAction restrictions and datepicker class I'm writing an application involved in time difference, there is something I don't get it, final DatePicker datePick=new DatePicker(); LocalDate time; Label label=new Label(); datePick.setOnAction(new EventHandler<ActionEvent>(){ public void handle(ActionEvent e){ time=datePick.getValue();//doesn't work, must 'LocalDate time=datePick.getValue(); label.setText(time);//doesn't work must label.setText("Time now:"+time) } }); It gives an error saying "Local variables referenced from an inner class must be final or effectively fine", anyway, all I did, declare 'time' variable inside setOnAction() and it worked, so what was wrong? and 'label.setText(time);' if I don't write some text inside, like 'label.setText("Time now: "+ time);' ,won't work too, that's weird, yet...

How to getValues() with Google Script from Sheets so the date values matches

Image
Clash Royale CLAN TAG #URR8PPP How to getValues() with Google Script from Sheets so the date values matches I have a range of cells which contain dates in the following format: 7/27/2018 17:03:46 When I use: var range = spreadsheet.getRange(1, 1, 20).getValues(); Logger.log(range[1][0]); I get Sat Jul 28 02:03:46 GMT+02:00 2018 instead of 7/27/2018 17:03:46 How do I get the correct value? My Timezone is GMT +02:00 I've tried using new Date(). The link below will take you to the Spreadsheet: https://docs.google.com/spreadsheets/d/1H7MAEfr0QbFuNwA8N_bm-08f_Phs8G2NNOQDYG-IA4E/edit?usp=sharing How about using getDisplayValues() instead of getValues() like var range = spreadsheet.getRange(1, 1, 20).getDisplayValues(); ? By this, the displayed values can be retrieved. The document is here. If this was not useful for your situation, I'm sorry. – Tanaike 14 mins ago ...

Unexpected values when unmarshalling data and currency attributes using JAXB

Image
Clash Royale CLAN TAG #URR8PPP Unexpected values when unmarshalling data and currency attributes using JAXB I am trying to umarshall xml response to java pojo. Having issues with date and currency values while unmarshalling using jaxb Results of unmarshalling, the currency field value not getting mapped(null) and date field is mapped to some numbers(like 1503979200000) Could someone please let me know where I am going wrong? Thanks in advance for your help. Below is my code: @XmlRootElement( name = "item" ) @XmlAccessorType(XmlAccessType.FIELD) public class Item{ @XmlElement( name = "bl" ) @XmlJavaTypeAdapter(DateTimeAdapter.class) private Date docDate; @XmlElement( name = "sd" ) @XmlJavaTypeAdapter(DateTimeAdapter.class) private Date dueDate; @XmlElement( name = "bu" ) @XmlJavaTypeAdapter(DateTimeAdapter.class) private Date postingDate; @XmlElement( name = "wr" ) @XmlJavaTypeAdapter(CurrencyAdapter.class) private Currency ...

Parsing dates with negative year in Go?

Image
Clash Royale CLAN TAG #URR8PPP Parsing dates with negative year in Go? How do I parse the date "3 Mar -1500" to represent 1500 BC? https://play.golang.org/p/akqQPj4mLeo According to the time.Parse function documentation: Years must be in the range 0000..9999. – Ortomala Lokni 13 hours ago 1 Answer 1 Here is a first draft that illustrates the concept: package main import ( "fmt" "strings" "time" ) func parseCEDate(value string) (time.Time, error) { const layout = "_2 Jan 2006" date, err := time.Parse(layout, value) if err == nil { return date, err } perr, ok := err.(*time.ParseError) if !ok { return time.Time{}, err } if perr.LayoutElem != "2...

Time validation always return false. PHP DateTime, Laravel

Image
Clash Royale CLAN TAG #URR8PPP Time validation always return false. PHP DateTime, Laravel I'm trying to create a controller for validation for time variable date and time. The problem is the code can validate the date and check in time correctly but always getting false value for check out time. Every variable of $checkOut always ended validate as Not Valid, Wrong Check Out Time Format . $checkOut Not Valid, Wrong Check Out Time Format function validateTime($time) { $d = DateTime::createFromFormat('H:i:s', $time); return $d && $d->format('H:i:s') == $time; } function validateDate($id, $date, $checkIn, $checkOut) { $d = DateTime::createFromFormat('Y-m-d', $date); $valid = ($d && $d->format('Y-m-d') == $date); if ($valid == false) { $data = "Not Valid, Wrong Date Format"; return $data; } else { $validCheckIn = $this->validateTime($checkIn); $validCheckOut = $thi...

when converting text/string to date in postgres, random date is generated

Image
Clash Royale CLAN TAG #URR8PPP when converting text/string to date in postgres, random date is generated I have a text column indicating date i.e. 20170101 UPDATE table_name SET work_date = to_date(workdate, 'YYYYMMDD'); I used this command to convert it as date. However, I got a odd result. I read though other existing posts but not sure what's wrong here. +----------+---------------+ | workdate | work_date | +----------+---------------+ | 20170211 | 2207-05-09 | | 20170930 | 2209-04-27 | | 20170507 | 2208-02-29 | | 20170318 | 2207-08-24 | +----------+---------------+ Is that table is your expected result? – Prashant Pimpale 1 hour ago Works for me: imgur.com/a/uEkIaeh – a_horse_with_no_name 54 mins ago ...

List all pages in a Jekyll site by date last updated

Image
Clash Royale CLAN TAG #URR8PPP List all pages in a Jekyll site by date last updated I'm using the last_modified_at plugin to display the most recent version of each page of my Jekyll site on each page and it works like a charm. Question: How do I list all of the pages on the site, most recently updated to oldest? I can create a list of all pages for the entire site with: {% for page in site.pages %} {{ page.title}} | {{ page.last_modified_at | date: '%s' }} {% endfor %} It shows the title and then the UTC time that the page was last updated. The goal is to order this list by the last_modified_at date. last_modified_at How do I build this correctly? By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

I have excel dates entered as 1/9/18, and I'd like to change them to 1/1/09

Image
Clash Royale CLAN TAG #URR8PPP I have excel dates entered as 1/9/18, and I'd like to change them to 1/1/09 In the format 1/9/18 the date is wrong. But the true date is made up of the wrong dates' month as month and day as year. So I'd like to convert 1/9/18 to 1/1/09 meaning January 1, 2009. What is the rule that says 1/9/18 should be converted to 1/1/09 ? – мυѕτавєւмo 6 mins ago 1/9/18 1/1/09 1 Answer 1 If your computer's regional system uses a DMY 'short date' then put this in an unused column to the right. =date(2000+month(a2), day(a1), 1) But if your computer's regional system uses a MDY 'short date' then put this in an unused column to the right. =date(2000+day(...

How to exclude weekends between two date ranges

Image
Clash Royale CLAN TAG #URR8PPP How to exclude weekends between two date ranges I have a FromDate and ToDate and days interval between them. Now i want to get all date excluding weekends If there is any weekends between my FromDate and ToDate,then this date will be increment by 2 days saturday and sunday. In below example, i have calculated all date between 7/27/2018 and 8/27/2018 with 5 days interval between them, public function testdate(){ $date_from = new DateTime("7/27/2018"); $date_to = new DateTime("8/27/2018"); $interval = new DateInterval("P5D"); $dates = new DatePeriod($date_from, $interval, $date_to); $out = array(); if (!empty($dates)) { foreach($dates as $dt) { $out = array( 'month_year' => $dt->format('d/m/Y') ); } } '<pre...

MSSQL - GROUP BY Date statement showing wrong data

Image
Clash Royale CLAN TAG #URR8PPP MSSQL - GROUP BY Date statement showing wrong data I have a GROUP BY statement which sort my data based on weeks. The problem here is my data are not being counted for the whole week (Sundays are not counted in) Here is an example: CREATE TABLE [dbo].[Products]( [ProductNR] [varchar](14) NULL, [Location] [int] NULL, [Date] [datetime] NULL); INSERT INTO Products (ProductNR, Location, Date) VALUES ('12345678911' ,1, '2018-07-16 00:00:00.000'), -- Monday ('12345678912' ,1, '2018-07-16 00:00:00.000'), -- Monday ('12345678913' ,1, '2018-07-16 00:00:00.000'), -- Monday ('12345678914' ,1, '2018-07-16 00:00:00.000'), -- Monday ('12345678915' ,2, '2018-07-16 00:00:00.000'), -- Monday ('12345678916' ,3, '2018-07-22 00:00:00.000'); -- This is a sunday And here is my Sql query in which it retrives the above data split for on 2 weeks when it supposed to be the count for jus...

How to get difference between two string dates

Image
Clash Royale CLAN TAG #URR8PPP How to get difference between two string dates There are two dates which are in string formats. String date1 = Thu Jul 26 13:45:49 IST 2018 String date2 = Wed Feb 26 17:31:27 IST 2016 How to get difference between these two dates? Possible duplicate of Calculating the difference between two Java date instances – Draken 9 mins ago @Draken Actually, that link says what to do when you already have some sort of date object representation. I'd be curious to see an answer which does the parsing the Java 8 way. – Tim Biegeleisen 7 mins ago Possible duplicate of compare dates in String format – LuCio 6 mi...

Calculate days in month with getDate Javacript

Image
Clash Royale CLAN TAG #URR8PPP Calculate days in month with getDate Javacript I'm using the following JS to calculate X days ahead of today's date. The output seems to work fine, except the result doesn't consider the days in each month. Therefore, if today is the 26th and I add 9 days, it's outputting the day as the 35th which obviously doesn't make sense. <script> window.onload=function(){ var dateObj = new Date(); var months = ['January','February','March','April','May','June','July','August','September','October','November','December']; var month = months[dateObj.getMonth()]; //months from 1-12 var day = dateObj.getUTCDate() +9; var year = dateObj.getUTCFullYear(); newdate = day + " " + month + " " + year; document.getElementById("date").innerHTML=(newdate); } </script> How can we get it to output the ac...